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.
For more details and current parameters, refer to the LoadTextFile or LoadTextFileRange methods in the SheetView class.
For instructions for saving to text files, see Saving to a Text File.
Use any of the LoadTextFile methods in the SheetView class (for the ActiveSheet or Sheets object).
This example opens a text file and handles the headers and specifies the delimiters.
C# |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.LoadTextFile("C:\\textfile.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, "\n", ",", ""); |
VB |
Copy Code
|
---|---|
fpSpread1.ActiveSheet.LoadTextFile("C:\textfile.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, Chr(10), ",", "") |
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.