Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

change text file delimitter

Hi,
I would like the end user to be able to set the delimiter for a csv text file. I can do this myself in design mode. I tried the code below in the Report.BeforePrint as well as in AssignPreviewFormSettings, but the delimiter remained the semicolon I had in the designer. I also tried the custom delimiter setting but that did not work either. Just setting the ftComma in the wrong place?? Thanks anybody.

ppMyRpt.TextFileType:= ftComma;

Comments

  • Hi Scott,

    The Report.BeforePrint event fires too late (in RAP) to alter the TextFileType. Try using an event that fires earlier such as the Report.OnInitializeParameters instead. In my quick testing, this worked correctly.

    If you are using the custom delimiter setting ftCustDelimiter, you will need to manually set the TppTextFileDevice.FieldDelimiter property to the delimiter you wish to use. This can be done in the OnFileDeviceCreate event. The following is sample RAP code.
    procedure ReportOnFileDeviceCreate;
    var
    lDevice: TppTextFileDevice;
    begin

    if Report.FileDevice is TppTextFileDevice then
    begin
    lDevice := TppTextFileDevice(Report.FileDevice);
    lDevice.FieldDelimiter := ':)';
    end;

    end;

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Thanks, worked great!
Sign In or Register to comment.