Spread Windows Forms 13.0 Product Documentation
Spread Windows Forms 13.0 Product Documentation / Developer's Guide / Managing File Operations / Saving Data to a File / Saving to a Text File
In This Topic
    Saving to a Text File
    In This Topic

    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 sheet or a portion of the sheet 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.

    Using Code

    1. To save the entire sheet, use one of the SheetView class SaveTextFile methods, specifying the path and file name or stream, whether data or data and formatting is saved, whether headers are saved, and the custom delimiters, depending on the method you choose.
    2. To save a portion of a sheet, use one of the SheetView class SaveTextFileRange methods, specifying the starting row and column, the number of rows and columns to save, the path and file name or stream, whether data or data and formatting is saved, whether headers are saved, and the custom delimiters, depending on the method you choose.

    Example

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