Spread ASP.NET 6.0 Product Documentation
Opening a Text File
Send Feedback
Spread ASP.NET 6.0 Product Documentation > Developer's Guide > Managing File Operations > Opening Existing Files > Opening a Text File

Glossary Item Box

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 you specify. There are several LoadTextFile methods each with several options.

If the file uses custom delimiters, 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.

You can also open a file from inside Spread Designer.

For instructions for saving to text files, see Saving to a Text File.

Return to the overview at Opening Existing Files.

Using a Shortcut

Use one of the SheetView object’s LoadTextFile methods, specifying the path and file name or stream, whether data or data and formatting was saved, whether headers are included, and the custom delimiters, depending on the particular method you choose.

Example

This example code loads a text file that contains formatted data, headers, and custom delimiters.

C# Copy Code
// Load a text file with headers and custom delimiters.
FpSpread1.Sheets[0].LoadTextFile("c:\textfile.txt", False, FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^");
VB Copy Code
' Load a text file with headers and custom delimiters.
FpSpread1.Sheets(0).LoadTextFile("c:\textfile.txt", False, FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly, "#", "%", "^")

Using the Spread Designer

  1. Select the File menu.
  2. Choose the Open option.
  3. A dialog appears warning you that you will overwrite your existing settings if you open a file. Click Yes to continue with the file open.

    The Open dialog appears.

  4. Change the Files of type box to Text files (*.txt).
  5. Specify the path and file name of the file to open, and then click Open.

    If the file is opened successfully, a message appears stating the file has been opened.

  6. Click OK to close the Spread Designer.
© 2002-2012 GrapeCity, Inc. All Rights Reserved.