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 for which you call the method.
If the file uses custom delimiters (such as commas in csv files), 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.
If you upgraded from a version prior to version 5, then you may wish to replace any obsolete parameters in the LoadTextFile methods.
For instructions for saving to text files, see Saving to a Text File.
Return to Opening Existing Files.
Return to the overview of Managing File Operations.
This example opens a text file and handles the headers and specifies the delimiters.
fpSpread1.ActiveSheet.LoadTextFile("C:\\textfile.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, "\n", ",", "");
FpSpread1.ActiveSheet.LoadTextFile("C:\textfile.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, Chr(10), ",", "")
Using the Spread Designer
- From the File menu icon, select Open.
- A dialog appears warning you that this overwrites your existing settings if you open a file. Click Yes to continue with the file open.
- Change the Files of type box to Custom 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.
The Open dialog appears.
To open a comma-delimited file, change the Files of type box to Comma-delimited files (*.csv).
If the file is opened successfully, a message appears stating the file has been opened.