Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Managing File Operations > Saving Data to a File > Saving to a Text File |
You can save the data or the data and formatting in a sheet to a text file, using either default tab delimiters or custom delimiters (such as a comma for a csv file). In addition, you can specify whether headers are saved with the data.
Saving to a text file is done for individual sheets. If you want to save all the sheets in the component, you must save each sheet to a text file.
Tab-delimited files saved from the component contain data separated by tabs and carriage returns. Tab-delimited files can be opened, modified, and saved using any standard text editor. Delimited files contain data separated by user-defined delimiters, such as commas, quotation marks, or other delimiters.
You can save the entire spreadsheet or a portion of the spreadsheet data from the component to tab-delimited and delimited files.
If you upgraded from a version prior to version 5, then you may wish to replace any obsolete parameters in the SaveTextFile and SaveTextFileRange methods.
For more details on the methods and current parameters, refer to the SaveTextFile and SaveTextFileRange methods of the SheetView class.
For instructions for opening text files, see Opening a Custom Text File.
This example code saves a range of data and formatting to a text file, including headers and using custom delimiters.
C# |
Copy Code
|
---|---|
// Save a range of data and formatting to a text file. fpSpread1.Sheets[0].SaveTextFileRange(1, 1, 1, 2, "C:\\filerange.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^"); |
VB |
Copy Code
|
---|---|
' Save a range of data and formatting to a text file. FpSpread1.Sheets(0).SaveTextFileRange(1, 1, 1, 2, "C:\filerange.txt", FarPoint.Win.Spread.TextFileFlags.Unformatted, FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^") |