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

Glossary Item Box

ExportToTextFileU Method


See Also    DLL

Applies To

fpSpread control

Description

Saves a sheet to a Unicode text file and lets you specify the delimiters.

Syntax

C++

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

Visual Basic

fpSpread1.ExportToTextFileU(ByVal FileName As String, ByVal CellDelim As String, ByVal ColDelim As String, ByVal RowDelim As String, ByVal Flags As ExportToTextFileConstants, ByVal LogFile As String) As Boolean

Parameters

The following parameters are available:

Parameter Description
FileName Path and file name of the Unicode text file to create
CellDelim Cell delimiter
For more information about the cell delimiter, see the Remarks section.
ColDelim Column delimiter
RowDelim Row delimiter
If you do not provide a row delimiter, the control uses a carriage return/line feed as the delimiter.
Flags Whether to append or over-write the file, whether to export formatted or unformatted data, and whether to export column and row headers
You must specify whether to append or create a new file. If you do not specify other options, formatted data will be exported, without column and row header text.
Use the OR operator and combine the following values as indicated:
Constant Value Description
Use one of the following values:
ExportToTextFileCreateNewFile 1 To create a new text file
ExportToTextFileAppendToExistingFile 2 To append to an existing text file
Use the following value:
ExportToTextFileUnformattedData 4 To export data as unformatted data
Use one or both of the following values:
ExportToTextFileColHeaders 8 To export column header text
ExportToTextFileRowHeaders 16 To export row header text
Use the following value:
ExportToTextFileCheckBoxFalse 32 Writes the false value as 0
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 the ExportToTextFileU method to save a sheet to a Unicode text file. If you want to save the sheet to an ANSI text file, use the ExportToTextFile method.

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.

Use strings to specify the delimiters to separate your data in the text file. If you do not want to provide a column delimiter, specify "" as the delimiter. If you do not provide a row delimiter, the control uses a carriage return/line feed as the delimiter.

You can use more than one character as the delimiter, enabling you to insert field names around data. You can use the Visual Basic Chr() function in a delimiter; for example, use Chr(10) to specify a line feed.

If you have specified a column or row delimiter, a cell delimiter is automatically provided. The cell delimiter is provided if one of the following is true:

By default, the control provides double quotes (") as the cell delimiter. You can specify another delimiter, if you prefer.

If the data contains the character used as the column or row delimiter, the entire cell data is placed between the cell delimiter character. For example, if the column delimiter is a comma, the data ab,cd becomes "ab,cd". If the data contains the character defined as the cell delimiter, the character in the data is preceded by another cell delimiter; for example, ab,"cd becomes "ab,""cd". Only cells that have data that contains a delimiter character have cell delimiters applied to them.

Use the Flags parameter to specify whether formatted or unformatted data is saved to the text file. For more information about formatted and unformatted data, see Formatted and Unformatted Data. Also use the Flags parameter to specify whether to append the data to an existing file, or to create a new file, and to specify whether column and row headers are exported.

By default, text files with custom delimiters created using Spread or the Spread Designer have the extension .TXT. However, you may use any extension.

Tip: You might want to save to a Spread (.SS8) file in addition to exporting it to text so that you can open the Spread (.SS8) file for future modifications.

The following table summarizes the formats to which you can save data from a workbook or sheet:

To Save To . . . Use Method
Binary file (proprietary format) SaveToFile
Tab-delimited file SaveTabFile or SaveTabFileU
Delimited file (offers user-defined delimiters) ExportToTextFile or ExportRangeToTextFile
or ExportToTextFileU or ExportRangeToTextFileU
Excel-formatted file ExportExcelBook or ExportToExcel
HTML file ExportToHTML or ExportRangeToHTML
XML file ExportToXML or ExportRangeToXML
XML buffer ExportToXMLBuffer or ExportRangeToXMLBuffer
An array GetArray

Note that the SaveTabFileU and the ExportRangeToTextFileU and ExportToTextFileU methods are similar. If you want to save the entire sheet to a Unicode tab-delimited file, you might find it faster to use the SaveTabFileU method. If you want to save only a portion of the sheet, or if you want to define your own delimiters, use the ExportRangeToTextFileU or ExportToTextFileU method.

Return Type

True if successful; otherwise, False.

See Also

Formatted and Unformatted Data
Saving to a Text File

Sheet property

ExportRangeToTextFile, ExportRangeToTextFileU, ExportToTextFile, LoadTextFile, SaveTabFileU methods

DLL Correspondence

SSExportToTextFileU function

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