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;
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
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.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com