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

Preview multiple reports as one

edited December 2002 in Devices
Hi,

Does anyone know how to preview multiple reports as only if it was only one
?
I can do something like that if I send the report to printer, creating a
TppPrinterDevice as follows:

ppPrinterDev := TppPrinterDevice.Create(Self);
ppPrinterDev.Stackable := True;

In the first report :
ppPrinterDev.StartPrintJob := True

ppPrinterDev.EndPrintJob := False
ppPrinterDev.Publisher := ppReport.Publisher;
ppReport.PrintToDevices;

In the middle ones:
ppPrinterDev.StartPrintJob := False

ppPrinterDev.EndPrintJob := False
ppPrinterDev.Publisher := ppReport.Publisher;
ppReport.PrintToDevices;

and in the last one :
ppPrinterDev.StartPrintJob := False

ppPrinterDev.EndPrintJob := True
ppPrinterDev.Publisher := ppReport.Publisher;
ppReport.PrintToDevices;

This works fine if the DeviceType is set to Printer, but I cannot make a
preview of it (DeviceType set to Screen)

Any tips ?

Thanks,

Nuno Fonseca
Filosoft-Software, Lda

Comments

  • edited December 2002
    The easiest thing to do is going to be to dynamically build three section
    style subreports in an empty main report and then load the three reports
    into the subreports. Then print the main report.

    Here is an example of creating a subreport in code:
    http://www.digital-metaphors.com/tips/DynamicSubreportCreation.zip

    The main report demos #51 and 52 show how to use section style subreports in
    a main report.


    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited December 2002
    I haven?t explained myself correctly.
    The situation is as follows:
    The application supports batch report printing. The report is always the
    same, but the DBFile from where the report gets the data is different every
    time the report is printed during the batch. Imagine a file that has a
    different name every day. The user may select the start/end day, so we never
    know how many subreports we will need, unless we create an empty report with
    as many dinamically created subreports as needed, in wich case we can get
    more than 100 subreports. Currently we are opening the first file, printing
    the report, closing the file, opening the next one, printing the report ...
    until the last one (using the stackable TppPrinterDevice) and we get only
    one print job. Our customers are asking us for preview of the batch
    reporting.
    I took a look at the example you suggested, and have a question:
    When the first subreport ends, will the next one start in a new page, or
    will it start right were the first one ended ? We want to preview them as
    one, but not mixed in the same page.
    If we could use the TppScreenDevice as we do with the TppPrinterDevice it
    would be much easier for us, since we could keep the code we have in almost
    all our reports. Any chances we can get this done with the TppScreenDevice ?

    Thanks,

    Nuno Fonseca

  • edited December 2002
    You can dynamically create subreports to do that. Set the PrintBehavior
    property of the subreports to pbFixed and the subreports will print on a new
    page everytime. See the help on this property.

    The screen device is meant to preview a single report. You can't replace the
    screen device, because the TppViewer creates a TppScreenDevice internally
    and not from a factory. The only way the screen device could work that way
    is if you controlled the page navigation yourself and made the page requests
    in your own code. You'll have to print the reports silently to a TppDevice
    and cache the pages, as they request pages from different reports. Then you
    would have to connect the ScreenDevice' Publisher property to the
    Report.Publisher that you want to use for this range of pages. I don't know
    if it would work because the page object's absolute page numbers and
    absolute page count will be off overall.

    Problably the best thing to do is create subreports dynamically in code to
    an empty report and preview that single report to the screen before printing
    it.

    Cheers,

    Jim Bennett
    Digital Metaphors

This discussion has been closed.