Setting CRLF vs LF

Hi,

For exporting to CSV, we're using:
procedure TExcelFile.Save(const aStream: TStream; const fileFormat: TFileFormats; const delimiter: UTF16Char);

Since we are creating the files on Linux, the export contains LF. There are many Windows based applications that cannot read files where LF is used. Therefore we want to overrule LF to CRLF.

How can I set LF to CRLF when saving CSV files? (only for a specific export file, not globally)

Thank you.

Hi,
Save doesn't support changing the NewLine, because it already was too complex as it was and we didn't want to keep adding parameters. (most uses of save are just save(filename)). So we instead created a new method explicitly for all the cases of CSV exporting: Export.
You can use: TExcelFile.Export Method | FlexCel Studio for VCL and FireMonkey documentation

Note that the TextWriter in the first parameter can be a simple TStreamWriter from system.classes. So you can call this like:

  var tw := TStreamWriter.Create('csvWithNewLine.csv');
  try
    xls.Export(tw, TXlsCellRange.Null, #$0009, true, #13#10);
  finally
    FreeObj(tw);
  end;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.