|
FlexCel Studio for VCL/LCL
|
This method will create a new worksheet and load a text file into it.
procedure OpenText(const FileName: TFileName; const Delimiter: UTF16Char; const ColumnFormats: array of XLSColumnImportTypes); overload;
__fastcall OpenText(const TFileName FileName, const UTF16Char Delimiter, const array of XLSColumnImportTypes ColumnFormats);
|
Parameters |
Description |
|
const FileName: TFileName |
File to Open. |
|
const Delimiter: UTF16Char |
The character used to separate fields. |
|
const ColumnFormats: array of XLSColumnImportTypes |
An array of formats that you can supply so FlexCel knows which kind of data a column contains. For each column in the ColumnFormats array, you can specify:
|
If you need more control, for example to import a text file beginning on cell C4 of an existing worksheet, you should use the LoadFromTextDelim global method (on unit "UTextDelim").
To open a CSV file (Comma Separated Values):
OpenText('Filename', ',' );
To open a CSV file (Comma Separated Values) that uses ";" instead of "," to separate the fields:
//This is the way CSV is saved on countries where the "," and not the "." is the decimal separator.
OpenText('Filename', ';' );
To open a Tab Delimited file:
OpenText('Filename', #9 );
To open a Tab Delimited file, ignore the first column, try to convert the second to number, dates, etc, keep the third as text even if it is a number, and try to convert all the other columns to numbers, dates, etc:
OpenText('Filename', #9,[xct_skip, xct_General, xct_Text] )|
Copyright (c) 2002-2008 TMS Software. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|