Spread ASP.NET 14
Spread for ASP.NET 14 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.

    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.

    There are multiple SaveTextFile methods each with several options. For instance, you can specify whether headers are saved with the data using the setting of the IncludeHeaders enumeration.

    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.

    You can also save a file from inside Spread Designer. The Spread Designer saves the current sheet.

    For instructions for opening text files, see Opening a Text File.

    Using a Shortcut

    1. To save the entire sheet, call one of the SheetView object 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 particular method you choose.
    2. To save a portion of a sheet, call one of the SheetView object 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 particular 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", false, FarPoint.Web.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", False, FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^") 
    

    Using the Spread Designer

    1. Select the File menu.
    2. Choose the Save option.

      The Save As dialog appears.

    3. For the Save As type, select Text files (.txt).
    4. Specify the path and file name to which to save the file, and then click Save.
    5. Click OK to close the Spread Designer.
    See Also