ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Report editor / Nested reports
  • Creating a nested report
  • Principle
  • Example 1: Simple nested reports
  • Example to perform
  • Operations to perform
  • Example 2: Nested reports with different orientations (Landscape/Portrait)
  • Example to perform
  • Operations to perform
  • Specific features of secondary reports
  • Blocks in the secondary report
  • Orientation of secondary report
  • Page break in the secondary report
  • Secondary report based on a query with parameters
  • Secondary report based on a query that uses a specific connection
  • Secondary report printed from a Page Footer block
  • Displaying the total number of pages in the secondary report
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Creating a nested report

Principle

The creation of a main report containing several secondary reports is performed in several steps:
  1. Creating a main report.
  2. Creating the secondary reports. These reports can have a different orientation from the main report.
  3. Printing secondary reports in the main report with iPrintReport. This function must be used:
    • in the "Before printing" event of a block: the secondary report will be printed before this block.
    • in the "After printing" event of a block: the secondary report will be printed after this block.
      Caution: If the nested reports have different orientations, iParameter must be called in order to change the print orientation accordingly.
  4. Configuring the print of page headers and footers for the nested report (iNestedHeaderFooter). This function can be used:
    • in the opening code of the main report: it will be taken into account by all the nested reports that will be printed from the main report.
    • before printing the nested report: it will be taken into account by the following nested report.
  5. Printing the main report. For more details, see Printing a main report that includes several secondary reports.
Remark: To print reports with different orientations (portrait/landscape), we recommend that you use the sequencing of reports. This method can be easily implemented. For more details, see Sequencing reports.
Example 1: Simple nested reports

Example to perform

The "RPT_Orders" report is based on the "Orders" data file. This report is used to print the characteristics of each order (date, customer number, total amount, ...). A break on the "OrderNum" item is used to separate the different orders.
The "QRY_ProductOrdered" query selects all the products of a specified order. This query expects an order number as parameter.
The "RPT_ProductOrdered" report is based on the "QRY_ProductOrdered" query. This report only prints the products selected by the "QRY_ProductOrdered" query.
The "RPT_ProductOrdered" report corresponds to the secondary report. This report will be printed after each break.

Operations to perform

  1. Create the "RPT_Orders" report: this report corresponds to the main report.
    • Click New in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
  2. Create the "QRY_ProductOrdered" query. For more details, see Creating a query with parameters.
  3. Create the "RPT_ProductOrdered" report: this report corresponds to the secondary report.
    • Click New in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
      Remark: The Page footer block of this report will not be printed. For more details, see Blocks in the secondary report.
  4. Write the following code In the "After printing" of the block End of break of "RPT_Order" event:
    // Initialize the query and
    // pass as parameter the number of the order currently printed
    iInitReportQuery(RPT_ProductOrdered, MySource.OrderNum)
    // Print the nested report
    iPrintReport(RPT_ProductOrdered)
Example 2: Nested reports with different orientations (Landscape/Portrait)

Example to perform

The main report ("RPT_LANDSCAPE") is printed in landscape mode. A sub-report ("RPT_PORTRAIT") in portrait mode must be called for each printed element. The secondary report must be started (by changing the orientation) in the "Post-print" code of the body block of the main report. Then, the secondary report must restore the orientation of the main report at the end of print.

Operations to perform

  1. Create the "RPT_LANDSCAPE" report: this report corresponds to the main report.
    • Click New in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
    • Choose an orientation in landscape mode.
      Remark: This report can be any type of report that uses data coming from any source: file, query, table, programming, ...
  2. In the description of the main report, in the "Options" tab, check "Print the report as is".
  3. In the "Format" tab, specify the margins and the indent. Validate the description window of the report.
  4. Create the "RPT_PORTRAIT" report: this report corresponds to the secondary report.
    • Click New in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
    • Choose an orientation in portrait mode.
      Remark: This report can be any type of report that uses data coming from any source: file, query, table, programming, ...
  5. In the description of the secondary report, in the "Options" tab, check "Print the report as it is".
  6. In the "Format" tab, specify the same margins and the same indent as the ones specified for the main report. Validate the description window of the report.
  7. Write the following code in the "After printing" of the block PAGE FOOTER of "RPT_LANDSCAPE" event (main report):
    // Call to the report with a different orientation (portrait mode here)
    iPrintReport(RPT_PORTRAIT)
    // Note: If this secondary report includes a page footer, this page footer will not be printed.
Specific features of secondary reports

Blocks in the secondary report

By default, when printing a secondary report (with iPrintReport), all the blocks in the secondary report are printed except for the following blocks:
  • the Page header block.
  • the Page footer block.
To force these blocks to be printed, use iNestedHeaderFooter.
Remark: If the secondary report contains a table whose header is found in the Page header block, only the Page footer block will not be printed (all the other blocks will be printed). In this case, the Page header block will be printed before the first row of the table (found in the secondary report).

Orientation of secondary report

The secondary report and the main report can have different orientations. In this case, iParameter must be called to modify the print orientation accordingly.
Remark: To print reports with different orientations (portrait/landscape), we recommend that you use the sequencing of reports. This method can be easily implemented. For more details, see Sequencing reports.

Page break in the secondary report

The page breaks defined in a secondary report will be taken into account when printing the main report.

Secondary report based on a query with parameters

If the secondary report is based on a query with parameters, use iInitReportQuery to pass the parameters to the query. This function must be used before iPrintReport.

Secondary report based on a query that uses a specific connection

If the secondary report is based on a query that handles a specific connection, use iInitReportQueryConnection to run this query (and to pass parameters if necessary). This function must be used before iPrintReport.

Secondary report printed from a Page Footer block

If the secondary report is printed from a Page Footer block, its Page Footer blocks will not be printed.

Displaying the total number of pages in the secondary report

A page counter must be added into the main report in order for the pages counter to operate in the nested report. However, the counter found in the main report can be made invisible if necessary.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 11/22/2022

Send a report | Local help