Spread 8.0 Documentation
LoadTextFile Method
Support Options
ActiveX Reference > ActiveX Methods > LoadTextFile Method

Glossary Item Box

LoadTextFile Method


See Also    DLL    Example

Applies To

fpSpread control

Description

Loads a text file.

Syntax

C++

BOOL CSpreadSheet::LoadTextFile(LPCTSTR FileName, LPCTSTR CellDelim, LPCTSTR ColDelim, LPCTSTR RowDelim, long Flags, LPCTSTR LogFile);

Visual Basic

fpSpread1.LoadTextFile(By Val FileName As String, By Val CellDelim As String, By Val ColDelim As String, By Val RowDelim As String, Flags As LoadTextFileConstants, By Val LogFile As String) As Boolean

Parameters

The following parameters are available:

Parameter Description
FileName Path and file name of the text file to load
CellDelim String containing the cell delimiter
For more information about the cell delimiter, see the Remarks section.
ColDelim String containing the column delimiter
RowDelim String containing the row delimiter
The row delimiter is required for the method to return True.
Flags Whether the text file provides column and row header text, and whether the sheet maintains formatting settings when loading the text file
You can combine values 1, 2, and 4 using the OR operator.
Constant Value Description
LoadTextFileNoHeaders 0 The file does not provide header text
LoadTextFileColHeaders 1 The file provides column header text
LoadTextFileRowHeaders 2 The file provides row header text
LoadTextFileClearDataOnly 4 The sheet clears any existing data, but maintains existing formatting when loading the text file
LogFile Path and file name of log file to create
If you do not provide a file name, the export will not create a log file. If you do not want to create a log file, set this parameter to "".

Remarks

Use this method to load a text file that uses multiple delimiters, or delimiters other than tab characters. Use the LoadTabFile method to load a simple, tab-delimited file. Use the LoadFromFile method to load a Spread binary (.SS8) file.

This method is called for the current sheet setting unless you first set the Sheet property to specify the sheet with which you want to work.

If you want your file to be in a spreadsheet format, your text file must have delimiters so the fpSpread control can find the data and populate the sheet appropriately. The text file must have a row delimiter. If you do not specify a row delimiter, the control assumes that a carriage return/line feed is the row delimiter. If the text file does not have a cell or column delimiter, specify "" as the delimiter.

If the file uses a column or row delimiter, and the data itself contains that delimiter character, the control assumes that the data will have a cell delimiter (double quotes (") by default) around the cell's data containing the delimiter character. For example, if your column delimiter is a comma, and a cell contains the data ab,cd, the control assumes the data will be represented as "ab,cd" when reading the file. If a different cell delimiter was used in the file, you must specify it for your file to be read appropriately.

Note: If you are depending on the default cell delimiter value, do not use double quotes (") in your data, or you might encounter unexpected results.

Caution: Loading a text file into the control deletes the data currently in the control. The loaded file overwrites existing data. Also, if your sheet had more columns and rows than the loaded sheet, those columns and rows are removed. For example, if your sheet had 100 columns and rows of data, and the loaded sheet has 50 columns and rows of data, once the new sheet is loaded, the control only has 50 columns and rows.

Return Type

True if successful; otherwise, False.

See Also

Loading a Text File

Sheet property

ExportRangeToTextFile, ExportToTextFile, LoadFromFile, LoadTabFile methods

DLL Correspondence

SSLoadTextFile function

© 2002-2014 ComponentOne, a division of GrapeCity. All Rights Reserved.