You can open existing text files that are delimited, either files saved from Spread or delimited text files from other sources. The data from the file you open is placed in the sheet you specify. There are multiple LoadTextFile methods each with several options.
If the file uses custom delimiters, you must specify the delimiters so the component can correctly place the data within the sheet. If your file uses standard tab-delimited format, you need not use a method that lets you specify delimiters.
You can also open a file from inside Spread Designer.
For instructions for saving to text files, see Saving to a Text File.
Using a Shortcut
Use one of the SheetView object’s LoadTextFile methods, specifying the path and file name or stream, whether data or data and formatting was saved, whether headers are included, and the custom delimiters, depending on the particular method you choose.
Example
This example code loads a text file that contains formatted data, headers, and custom delimiters.
C# | Copy Code |
---|---|
// Load a text file with headers and custom delimiters. FpSpread1.Sheets[0].LoadTextFile("c:\textfile.txt", False, FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^"); |
VB | Copy Code |
---|---|
' Load a text file with headers and custom delimiters. FpSpread1.Sheets(0).LoadTextFile("c:\textfile.txt", False, FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^") |
Using the Spread Designer
- Select the File menu.
- Choose the Open option.
- The Open dialog appears.
- Change the Files of type box to Text files (*.txt).
- Specify the path and file name of the file to open, and then click Open.
- Click OK to close the Spread Designer.