Spread 8.0 Documentation
SSExportRangeToTextFile Function
Support Options
DLL Reference > DLL Functions > SSExportRangeToTextFile Function

Glossary Item Box

SSExportRangeToTextFile Function


See Also    ActiveX

Applies To

fpSpread control

Description

Saves the specified range of cells in a sheet to a text file.

Syntax

C

BOOL SSExportRangeToTextFile(HWND hWnd, SS_COORD lCol, SS_COORD lRow, SS_COORD lCol2, SS_COORD lRow2, LPCTSTR pcszFileName, LPCTSTR pcszCellDelim, LPCTSTR pcszColDelim, LPCTSTR pcszRowDelim, long lFlags, LPCTSTR pcszLogFile);

C++

BOOL TSpread::ExportRangeToTextFile(SS_COORD lCol, SS_COORD lRow, SS_COORD lCol2, SS_COORD lRow2, LPCTSTR pcszFileName, LPCTSTR pcszCellDelim, LPCTSTR pcszColDelim, LPCTSTR pcszRowDelim, long lFlags, LPCTSTR pcszLogFile);

Parameters

The following parameters are available:

Parameter Description
lCol Column number of first column in range to save to text
lRow Row number of first row in range to save to text
lCol2 Column number of last column in range to save to text
lRow2 Row number of last row in range to save to text
pcszFileName Path and file name of the text file to create
pcszCellDelim Cell delimiter
For more information about the cell delimiter, see the Remarks section.
pcszColDelim Column delimiter
pcszRowDelim Row delimiter
If you do not provide a row delimiter, the control uses a carriage return/line feed as the delimiter.
lFlags 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 Description
Use one of the following values:
SS_EXPORTTEXT_CREATE To create a new text file
SS_EXPORTTEXT_APPEND To append to an existing text file
Use the following value:
SS_EXPORTTEXT_UNFORMATTED To export data as unformatted data
Use one or both of the following values:
SS_EXPORTTEXT_COLHEADERS To export column header text
SS_EXPORTTEXT_ROWHEADERS To export row header text
Use the following value:
SS_EXPORTTEXT_CHECKBOXFALSE To write false as 0
pcszLogFile 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 NULL.

Remarks

This function is applied to the current sheet setting unless you first call the SSSetSheet function to specify the sheet for which you are calling this function.

Call the SSExportRangeToTextFile function to save a range of cells in a sheet to an ANSI text file. If you want to save a range of cells to a Unicode text file, call the SSExportRangeToTextFileU function.

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.

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 lCol, lRow, lCol2, and lRow2 parameters to specify which cells to export. For example, you can use the SSN_BLOCKSELECTED message to determine which range of cells the user has selected, and then pass that range to the SSExportRangeToTextFile function to export the selected range.

Use the lFlags 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 lFlags 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 can use any extension.

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

Only the specified cells in the specified sheet are exported to the text file. If you want to export an entire sheet, call the SSExportToTextFile function instead.

The following table summarizes the formats to which you can save data:

To Save To . . . Use Function
Binary file (proprietary format) SSSaveToFile
Tab-delimited file SSSaveTabFile or SSSaveTabFileU
Delimited file (offers user-defined delimiters) SSExportToTextFile or SSExportRangeToTextFile
or SSExportToTextFileU or SSExportRangeToTextFileU
Excel-formatted file SSExportExcelBook or SSExportToExcel
HTML file SSExportToHTML or SSExportRangeToHTML
XML file SSExportToXML or SSExportRangeToXML
XML buffer SSExportToXMLBuffer or SSExportRangeToXMLBuffer
An array SSGetArray

Note that the SSSaveTabFile and the SSExportRangeToTextFile and SSExportToTextFile functions are similar. If you want to save the entire sheet to a tab-delimited file, you might find it faster to call the SSSaveTabFile function. If you want to save only a portion of the sheet, or if you want to define your own delimiters, call the SSExportRangeToTextFile or SSExportToTextFile function.

Return Type

True if the function completes successfully; False otherwise.

See Also

Saving to a Text File

SSExportRangeToTextFileU, SSExportToTextFile, SSExportToTextFileU, SSLoadTextFile, SSSaveTabFile, SSSetSheet functions

ActiveX Correspondence

ExportRangeToTextFile method

Copyright © GrapeCity, inc. All rights reserved.