I have a report with fields I save to a CSV file. However if the field is a stringfield it places "" around it. Is there anyhow I can prevend this from happening?
ReportBuilder 11 includes enhancements to the TextFileDevice to control the quoting in a delimited text file. To remove all quotes you will want to manually set the TppTextFileDevice.QuoteChar to an empty string ('').
In order to set the extended properties of the TppTextFileDevice you need to manual create the TppTextFileDevice and assign the Publisher property to the report's publisher. You would then use the PrintToDevices method in replace of the Print method to export the report to a text file.
Because you are manually creating the output device (TppTextFileDevice) and calling PrintToDevices to export the file, you do not need to set the device and export related properties of the TppReport, including ppReport.DeviceType, ppReport.TextFileName and ppReport.TextFileType, as they are no longer used. Just make sure to set the equivalent properties of the TppTextFileDevice object.
var lTextFileDevice: TppTextFileDevice; ... begin ...
For RB 11 there is a new OnFileDeviceCreate event that can be used to do this. When you call Report.Print with the device type set to one of the file devices, then this event will fire just after the file device is created.
This is from the RBuilder.hlp topic for OnFileDeviceCreate
This event fires after a FileDevice has been created. You can access the FileDevice via the FileDevice property. You can typecast the FileDevice and to configure its properties. Example:
uses ppPDFDevice;
var lPDFDevice: TppPDEFDevice;
begin if (myReport.FileDevice is TppPDFDevice) then begin lPDFDevice := TppPDFDevice(myReport.FileDevice);
// add code here to configure PDFDevice properties...
end;
end;
-- Nard Moseley Digital Metaphors www.digital-metaphors.com
Best regards,
Nard Moseley Digital Metaphors www.digital-metaphors.com
Comments
ReportBuilder 11 includes enhancements to the TextFileDevice to control the
quoting in a delimited text file. To remove all quotes you will want to
manually set the TppTextFileDevice.QuoteChar to an empty string ('').
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
How do I do that, I have now RB 11 installed, but I cannot seem to find the
TppTextFileDevice.
Is it in code, in delphi designer or in runtime?
Best regards,
Rob Nowee
In order to set the extended properties of the TppTextFileDevice you need to
manual create the TppTextFileDevice and assign the Publisher property to the
report's publisher. You would then use the PrintToDevices method in replace
of the Print method to export the report to a text file.
Because you are manually creating the output device (TppTextFileDevice) and
calling PrintToDevices to export the file, you do not need to set the device
and export related properties of the TppReport, including
ppReport.DeviceType, ppReport.TextFileName and ppReport.TextFileType, as
they are no longer used. Just make sure to set the equivalent properties of
the TppTextFileDevice object.
var
lTextFileDevice: TppTextFileDevice;
...
begin
...
lTextFileDevice:= TppTextFileDevice.Create(ppReport);
lTextFileDevice.Publisher := ppReport.Publisher;
lTextFileDevice.TextFileType := ftComma;
lTextFileDevice.QuoteChar := '';
lTextFileDevice.FileName := 'some valid file location'
ppReport.PrintToDevices;
...
lTextFileDevice.Publisher := nil;
FreeAndNil(lTextFileDevice);
...
end;
Since you created the TppTextFileDevice you should also take responsibility
to destroy it as well.
I hope that at least points you in the right direction.
Scott
Thanks,
That did the trick.
Best regards,
Rob Nowee
For RB 11 there is a new OnFileDeviceCreate event that can be used to do
this. When you call Report.Print with the device type set to one of the file
devices, then this event will fire just after the file device is created.
This is from the RBuilder.hlp topic for OnFileDeviceCreate
This event fires after a FileDevice has been created. You can access the
FileDevice via the FileDevice property. You can typecast the FileDevice and
to configure its properties. Example:
uses
ppPDFDevice;
var
lPDFDevice: TppPDEFDevice;
begin
if (myReport.FileDevice is TppPDFDevice) then
begin
lPDFDevice := TppPDFDevice(myReport.FileDevice);
// add code here to configure PDFDevice properties...
end;
end;
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com