The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Unit: SDL_replist
Class: TRLData
Declaration: function ExportCSV (FName: String; Delimiter: TCSVDelimiters; IncludeColHeaders, IncludeCommonHeader: boolean; FirstCol, FirstRow, LastCol, LastRow: integer): integer;

The method ExportCSV writes the contents of the data table along with optional auxiliary information (headers, etc.) to the CSV file FName. The delimiting character is specfied by the parameter Delimiter.

The parameters IncludeColHeaders and IncludeCommonHeader control whether the column headers and the common header are exported, as well. The parameters FirstCol, FirstRow, LastCol and LastRow specify the range of cells to be exported. Setting both the low and the high column/row parameter of a dimension (i.e. FirstCol and LastCol) to zero values forces the method to export all elements of that dimension.

The method returns the following error codes:

 0 ... everything is OK
-1 ... file write error (disk full, invalid filename, etc...)
-2 ... invalid range of cells (FirstCol...LastRow)
-3 ... selected CSV delimiter must not be csvUnknown

Hint 1: Please note that the CSV format has never been standardized, and thus a plethora of different sub-versions exists. Further, the decimal separator and the thousand separator character change between different languages, contributing to even greater confusion. For example, in German implementations the comma is replaced by the semicolon in order to be able to use the comma as a decimal separator. Thus the selection of the delimiter depends on the system which will be used to read the CSV file.

Hint 2: ExportCSV triggers the OnPercentDone event to provide feedback during time consuming write operations.

Last Update: 2017-Nov-22