Components for Delphi and C++ Builder.

Go to Russian forum
Go to
It is currently 26 Feb 2024, 14:38

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 12 Aug 2022, 01:56 

Joined: 16 May 2019, 12:00
Posts: 1
I try to export data from grid to CSV but result was flawed.
Data was exported as one single line without any end of line.
There was 5 CRLF at file begining after that all data in one single line.
Check attached file.
  if SaveDialog1.Execute(Handle) then
    SaveDBGridEhToExportFile(TDBGridEhExportAsCSV, dbgData,
      SaveDialog1.FileName, True);

CPTreport.7z [301 Bytes]
Downloaded 65 times
PostPosted: 13 Aug 2022, 19:07 

Joined: 29 Oct 2013, 11:58
Posts: 13
from help file :


so ...use SaveDBGridEhToTextFile method.

procedure TForm1.Button4Click(Sender: TObject);
  Grid: TDBGridEh;
  Path: String;
  FileName: String;
ExportOptions: TDBGridEhTextExportOptions;

  ExportOptions := TDBGridEhTextExportOptions.Create;
  ExportOptions.IsExportTitle := True;   // columns titles
  ExportOptions.IsExportFooter := False;
  ExportOptions.Encoding := TEncoding.UTF8;
  ExportOptions.WriteBOM := True;
  ExportOptions.QuoteChar := '"';
  ExportOptions.CellDelimiter :=  ';';
  ExportOptions.TrailingLineDelimiter := True;
  ExportOptions.UseEditFormat := False;
  ExportOptions.LineDelimiter :=  sLineBreak;

  FileName := Path + '\DBGridEh1Export.csv';

  SaveDBGridEhToTextFile(DBGridEh, FileName, ExportOptions);

  ShellExecute(Handle, nil, PChar(FileName), nil, nil, SW_SHOWNORMAL);


TDBGridEhStringExportOptions class contains the following properties :

property ExportSelecting: Boolean;
Specifies to unload only the selected grid area. If property = False, then the entire grid will be unloaded regardless of the presence of the selected MultiSelect area.

property CellDelimiter: String;
A string separator of cells. Default #9 (Tab code).

property LineDelimiter: String;
Line separator string. The default is sLineBreak.

property TrailingLineDelimiter: Boolean;
The property specifies whether to unload the line separator after the last unloaded line.

property QuoteChar: Char;

Use QuoteChar to get or set the quote character that is used to enclose individual cell values if the value contains a substring that matches the value of the CellDelimiter, LineDelimiter, or QuoteChar property.

property IsExportTitle: Boolean;
The property specifies whether to write the column headings in the first row of the export.

property IsExportFooter: Boolean;
The property specifies whether to unload grid footers after unloading the split data.

property UseEditFormat: Boolean;
The property specifies that when receiving cell data as a string for numeric data and DateTime data, the string format used when editing the cell must be used. If property = False, then Column.DisplayFormat property will be used for formatting.

property FormatSettings: TFormatSettings;
The property specifies the format for numeric and DateTime values to be used when converting numbers and dates to text.

property UseFormatSettings: Boolean;
Set the property to True to indicate that the FormatSettings property should be used when converting numeric data.

property ExportColumns: TColumnsEhList;
List of columns to be exported. If the property is not filled, then all visible rows of the grid will be exported.

The TDBGridEhTextExportOptions class inherits from the TDBGridEhStringExportOptions class and has the following additional properties.

property Encoding: TEncoding;
The property specifies the character encoding that will be used when writing the exported data string to a stream or file.

property WriteBOM: Boolean;
Set the property to True to indicate to the algorithm that when writing data to a stream, a Byte Order Mark must be written to the beginning of the stream, which contains the encoding code in which the text data was written. For a description of the Byte Order Mark, see here:

Last edited by souarit on 13 Aug 2022, 21:39, edited 2 times in total.

PostPosted: 13 Aug 2022, 21:15 

Joined: 08 May 2014, 18:06
Posts: 653

We tested SaveDBGridEhToExportFile(TDBGridEhExportAsCSV...) on a simple Demo project and found no export issues.
EhLib 10.2.030, Delphi 11 Update 1.
Perhaps the problem depends on the grid settings, library version and Delphi.

Please write your version of the library and Delphi.
Please send a simple demo project in which the problem is reproduced.

sshot-254.png [ 54.68 KiB | Viewed 588 times ]

Best regards
EhLib Support Team
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 6 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group