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.
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.
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, "#", "%", "^") |