RAP Logic for Data Export
It seems like there should be a simple problem for what I am trying to
accomplish, so I thought I would post this issue before making any
further code changes (e.g. RTTI) in RAP.
GOAL:
I have a very common need with a number of reports I have developed. I
want a nicelt formatted page header (shows up on every page) for when a
report is previewed, printed and exported to a format such as pdf.
I want the same report to allow an easy export of the data in the
detail band with a single line of field names.
I know that having a header band for the 'printed' format and a title
band for the 'exported' format gets me most of the way there.
RAP does not seem to have any way of knowing what kind of file I select
when I choose 'Print To File', nor any way of knowing that I have
selected 'Print to File'. I have extended RAP using RTTI to include
the PrintDialog.PrintToFile and PrintDialog.DeviceType properties.
This allows me to turn the visibility of the header/title band to the
right value for the context I am interested in.
PROBLEM:
I have a dbMemo field in many of my reports for long fields and a
corresponding dbText field for the same data field. When I am printing
to the screen, the printer, or exporting to a pdf, I want the wrapping
value of the dbMemo field, when I am exporting, I need the dbText field
as it does not appear to be possible to export the dbMemo field.
However, in order to access the PrintDialog properties, I must wait
until the OnPrintDialogClose event has been called. At this point, the
report engine has rendered the dbMemo field visible on the screen.
When I set this to invisible and the corresponding dbText field to
visible, the report engine seems to get horribly confused.
Report.Engine.Reset does not appear to ba available in RAP, I can try
adding this to RTTI, but I thought I would throw this out there first
to see if this is a viable approach. If I add an RTTI function, I will
need to redistribute my application, something I would like to avoid if
possible.
I am also hoping that there is an easier solution out there. I can add
a parameter for when the report is called and evaluate that in the
BeforePrint event, but that seems less elegant. I would like the user
to see a nicely formatted header in the previewer before they export
the data.
--
Bob McClintock
accomplish, so I thought I would post this issue before making any
further code changes (e.g. RTTI) in RAP.
GOAL:
I have a very common need with a number of reports I have developed. I
want a nicelt formatted page header (shows up on every page) for when a
report is previewed, printed and exported to a format such as pdf.
I want the same report to allow an easy export of the data in the
detail band with a single line of field names.
I know that having a header band for the 'printed' format and a title
band for the 'exported' format gets me most of the way there.
RAP does not seem to have any way of knowing what kind of file I select
when I choose 'Print To File', nor any way of knowing that I have
selected 'Print to File'. I have extended RAP using RTTI to include
the PrintDialog.PrintToFile and PrintDialog.DeviceType properties.
This allows me to turn the visibility of the header/title band to the
right value for the context I am interested in.
PROBLEM:
I have a dbMemo field in many of my reports for long fields and a
corresponding dbText field for the same data field. When I am printing
to the screen, the printer, or exporting to a pdf, I want the wrapping
value of the dbMemo field, when I am exporting, I need the dbText field
as it does not appear to be possible to export the dbMemo field.
However, in order to access the PrintDialog properties, I must wait
until the OnPrintDialogClose event has been called. At this point, the
report engine has rendered the dbMemo field visible on the screen.
When I set this to invisible and the corresponding dbText field to
visible, the report engine seems to get horribly confused.
Report.Engine.Reset does not appear to ba available in RAP, I can try
adding this to RTTI, but I thought I would throw this out there first
to see if this is a viable approach. If I add an RTTI function, I will
need to redistribute my application, something I would like to avoid if
possible.
I am also hoping that there is an easier solution out there. I can add
a parameter for when the report is called and evaluate that in the
BeforePrint event, but that seems less elegant. I would like the user
to see a nicely formatted header in the previewer before they export
the data.
--
Bob McClintock
This discussion has been closed.
Comments
- try leaving the Memo.Visible to true for all cases and just toggle the
DBText.Visible. (The Memo is a stretchable object and can affect
pagination - so that might be causing the engine to get confused.)
- from the Report.BeforePrint event you can check Report.FileDevice <> nil
via RAP, but are correct that does not tell you what type of file format is
being generated. For that I think you need some RAP RTTI
--
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
Best regards,
Nard Moseley
Digital Metaphors
www.digital-metaphors.com
I already had put in the RTTI logic for the PrintDialog.FileDevice, so
I am all set.
Thanks.