ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
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 states 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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
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:
    • or in the "Before printing" event of a block: the secondary report will be printed before this block.
    • or in the "After printing" event of a block: the secondary report will be printed after this block.
      Caution: If nested states have different orientations, you need to call function iParameter 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 apply to all the nested reports that will be printed from the main report.
    • before printing the nested report: it will only apply to the next nested report.
  5. Printing the main report. For more details, see Printing a main report that includes several secondary reports.
Note: To print using reports with different orientations (portrait/landscape), we recommend using the report chain. 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 window for creating a new element is displayed: 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 window for creating a new element is displayed: click "Report" then "Report".
      Remark: The 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:
    // Initialiser la requête et
    // passer en paramètre le numéro de commande en cours d'impression
    iInitReportQuery(ETAT_ProduitCommandé, MySource.NumCommande)
    // Imprimer l'état imbriqué
    iPrintReport(ETAT_ProduitCommandé)
Example 2: Nested states 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 "PAYROLL_STATUS" report: this report corresponds to the main report.
    • Click New in the quick access buttons.
    • The window for creating a new element is displayed: click "Report" then "Report".
    • Choose an orientation in landscape mode.
      Remark: This report can be an report of any type using data 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. On the "Format" tab, specify the margins and the indent. Validate the description window of the report.
  4. Create the "PORTRAIT_STATUS" report: this report corresponds to the secondary report.
    • Click New in the quick access buttons.
    • The window for creating a new element is displayed: click "Report" then "Report".
    • Choose an orientation in portrait mode.
      Remark: This report can be an report of any type using data 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. On 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):
    // Appel de l'état qui a une orientation différente (donc en portrait ici)
    iPrintReport(ETAT_PORTRAIT)
    // Note: Si cet état secondaire à un bas de page, ce bas de page ne sera pas imprimé.
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.
Note: If the secondary report contains an array whose header is present in block Header of Page, only block Footer of Page will not be printed (all 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.
Note: To print using reports with different orientations (portrait/landscape), we recommend using the report chain. 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: 09/18/2024

Send a report | Local help