Easiest way of supressing formatting when printing to file?
I have a given report with currency fields with display format set to
",0.00;(,0.00);0"
When printing to a text file, the commas cause problems if imported into
Excel. What is the easiest way to supress this formatting for this purpose?
Note that I am using the standard preview form and the print to file is
occuring from there.
John
",0.00;(,0.00);0"
When printing to a text file, the commas cause problems if imported into
Excel. What is the easiest way to supress this formatting for this purpose?
Note that I am using the standard preview form and the print to file is
occuring from there.
John
This discussion has been closed.
Comments
If you check the device type in the Report.BeforePrint event, you'll notice
that the report's device type is never changed, even though you've selected
a different device type in the print dialog. This is done, so that the next
time you print, the device type will be what it originally was. You'll need
to reference the Report.PrintDialog.DeviceType property to compare it to
dtTextFile.
if ppReport1.PrintDialog.DeviceType <> dtTextFile then
ppDBText1.DisplayFormat := '$#,0.00;($#,0.00)'
else
ppDBText1.DisplayFormat := '0.00;-0.00';
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
Will this code address subreports, or do I have to figure that one out on my
own?
Thanks,
-------------------------
procedure ToggleCurrencyFormatsForTextExport(const aReport : TppReport);
procedure ToggleBand(const aBand : TppBand; const aMask : string);
var
i: Integer;
localDBText : TppDBText;
begin
for i := 0 to aBand.ObjectCount - 1 do
begin
if (aBand.Objects[i] is TppDBText) then
begin
localDBText := TppDBText(aBand.Objects[i]);
if
localDBText.DataPipeline.GetFieldDataType(localDBText.DataField) =
dtCurrency then
begin
localDBText.DisplayFormat := aMask;
end;
end;
end;
end;
const
STR_TEXTEXPORT = '0.00;-0.00;0';
STR_STDFORMAT = ',0.00;-,0.00;0';
var
localBand : TppBand;
localIsPrintingToText : boolean;
localMask : string;
i: Integer;
begin
localIsPrintingToText := (aReport.PrintDialog.DeviceType = dtTextFile);
if localIsPrintingToText then
localMask := STR_TEXTEXPORT
else
localMask := STR_STDFORMAT;
for i := 0 to aReport.BandCount - 1 do
begin
ToggleBand(aReport.Bands[i], localMask);
end;
end;
look for TppSubreport, then call the ToogleCurrency() passing
Subreport.Report as the parameter.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
John
BeforePrint event will fire both when the report is previewed to the screen,
and when the report is printed. Checking for nil is always a good thing.
Cheers,
Jim Bennett
Digital Metaphors Corp
http://www.digital-metaphors.com
info@digital-metaphors.com