PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
This content has been translated automatically. Click here to view the French version.
  • Overview
  • Report on independent query
  • Overview
  • Creating a report on independent query
  • Report on embedded query
  • Overview
  • Creating a report on embedded query
  • Using an item of the embedded query from a code of the report
  • Report on query with parameters
  • Printing a report based on a query
  • Printing a report based on a query without parameters
  • Printing a report based on a query with parameters
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
Overview
Queries are used to easily select records in one or more data files. Queries can also be used to perform calculations on the selected data. You can, for example, select all the orders for the customers living in New York City and calculate the total amount of orders per customer.
Using queries in a report allows you to easily create complex reports. The query pre-selects the records and the report organizes the selected data and performs the different calculations.
Caution: To optimize the report, we advise you to perform the calculations (totals on items for example) in the report (and not in the query).
Versions 18 and later
iPhone/iPad This feature is now available for iPhone/iPad applications.
New in version 18
iPhone/iPad This feature is now available for iPhone/iPad applications.
iPhone/iPad This feature is now available for iPhone/iPad applications.
Versions 21 and later
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Versions 25 and later
Android This feature is now available for Android applications.
New in version 25
Android This feature is now available for Android applications.
Android This feature is now available for Android applications.
Several modes can be used to create a report based on a query:
  • the query is created and saved in the query editor. The report is based on the file corresponding to the query ( .WDR file). The query can be re-used in another report, window, control, ... The query can be modified at any time in the query editor. The query is said to be independent. For more details, see Report on independent query.
  • the query is created when creating the report. The query is included in the report. No file specific to the query is created. The query can only be modified from the report where it was created. It cannot be re-used in another report, window, control, ... The query is said to be embedded. For more details, see Report on embedded query.
  • the query is based on data coming from a connection (not available in WINDEV Mobile). For more details, see Create an SQL query via a connection (ODBC, Native Connector , ...).
    Remark: This type of report on query is available even if no analysis is associated with the WINDEV or WEBDEV project.
Tip: You have the ability to create, from the query editor, a report based on the current select query. To do so, on the "Query" tab, in the "Data binding" group, click "Create a report".
Remark: An independent query or an embedded query can accept parameters. For more details, see Report on query with parameters.
The report can be easily printed from your WLanguage programs. For more details, see Printing a report on query. This help page presents:
Report on independent query

Overview

The query must be created before the report (for more details, see Create a query). When creating the report, all you have to do is specify the name of the query used.
If the query is modified in the query editor (deletion of result items for example), a synchronization screen is displayed when closing the query. This allows you to apply the modifications performed on the query to all elements that use this query (including reports).

Creating a report on independent query

To create a report on independent query:
  1. Click New in the quick access buttons.
    • The element creation window appears: click "Report" then "Report".
    • The report creation wizard starts.
  2. Choose the layout of your report (table, form, label, ...). For more details, see The different types of reports.
  3. Select (if necessary) the report template to use. A report template is used to comply with a specific page layout. For more details on report templates, see Report templates.
  4. Select the data source of report ("From a data file or from an existing query").
  5. Select the query on which the report will be based. Only the queries found in the current application are proposed.
  6. To group the records, you have the ability to create breaks on the sort items. To create breaks, answer "Yes" to the question "Do you want to add some breaks into the report?".
    The wizard next step is used to select the sort items corresponding to the breaks. For more details on breaks, see Breaks in a report .
  7. For each item displayed in the report:
    • type the corresponding caption. This caption will be displayed:
      • before the item. For example:
        =Caption
      • in the column header (for the Table reports). For example:
        =Caption
        This caption can be modified in the report editor.
    • select the block where the control associated with the item will be printed. The positions of different controls can be modified in the report editor. For more details on the different blocks and their position in a report, see Report blocks.
  8. Modify (if necessary) the display order of controls in the report with the arrow buttons found on the right of table.
  9. If the query associated with the report contains at least one numeric item, you have the ability to perform calculations these items. Specify the calculation performed for each item (sum, average, ...). Two types of calculations are available:
    • general calculation: a Calculated control will be created in the End of document block.
    • calculation on break: a Calculated control will be created in the Break footer block. In the calculations on break, the result of the calculation is reinitialized after each break. To perform a calculation on break, a break must be found in the report currently created.
  10. Depending on the type of report currently created, indicate the specific options.
    Type of reportSpecific options
    Report on formForm image, printing the form image, ...
    Options presented in Report on form
    Label reportFormat of labels, number of identical copies, ...
    Options presented in Label report
  11. Specify the format of sheet on which the report will be printed. The report is printed in A4 format by default.
    Remark: By default, the report controls are displayed in a single column. To create a multi-column report, simply specify the desired number of columns in the "Format" tab of the report description window.
  12. Select the skin template of the report if necessary.
  13. Type the name and title of the report (name of ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
    WINDEV You can also specify whether the report can be modified by the end user in "Reports & Queries".
  14. Validate the report creation.
  15. The report editor automatically proposes to change the report format if the following conditions are fulfilled:
    • the report currently created includes a table.
    • the report format does not allow to display all table columns.
  16. Specify (if necessary) the mode for reducing the report size:
    • Versions 19 and later
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
      New in version 19
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
    • Use the landscape mode.
    • Reduce the report size. Caution: according to the reduction percentage, the printed report may become unreadable.
  17. The report currently created is displayed in the report editor.
Report on embedded query

Overview

The query is created when creating the report. This query will be modified from the report editor ("Edit the query" from the popup menu of the report). If modifications are performed in the query, the report editor lists these modifications as well as their incidence on the report.
Remark: To switch from the embedded mode to the independent mode (which means to extract a query from a report):
  1. Display the report based on the embedded query (in the report editor).
  2. Select "Edit the query" from the popup menu of report. Another solution: on the "Modification" tab, in the "Report" group, click "Edit query". The query is displayed in the query editor.
  3. On the "Home" tab, in the "General" group, expand "Save" and select "Export .. To an independent query".
  4. Save the new query.

Creating a report on embedded query

To create a report on embedded query:
  1. Click New in the quick access buttons.
    • The element creation window appears: click "Report" then "Report".
    • The report creation wizard starts.
  2. Choose the layout of your report (table, form, label, ...). For more details, see The different types of reports.
  3. Select (if necessary) the report template to use. A report template is used to comply with a specific page layout. For more details on report templates, see Report templates.
  4. Select the data source of report ("From a new query").
  5. The query creation wizard starts. Select the items used by the query.
    Remark: To simplify the selection of items, display them in alphabetical order or by associated file.
  6. Define the characteristics of the query (selection condition, group, sorting, ...) by clicking on the corresponding button.
    For more details, see:
  7. Go to the next step.
  8. To group the records, you have the ability to create breaks on the sort items defined in the query. To create breaks, answer "Yes" to the question "Do you want to add some breaks into the report?".
    The next step is used to select the sort items corresponding to the breaks. For more details on breaks, see Breaks in a report.
  9. For each query item displayed in the report:
    • type the corresponding caption. This caption will be displayed:
      • before the item. For example:
        Libellé
      • in the column header (for the Table reports). For example:
        =Caption
        This caption can be modified in the report editor.
    • select the block where the control associated with the item will be printed. The positions of different controls can be modified in the report editor. For more details on the different blocks and their position in a report, see Report blocks.
  10. Modify (if necessary) the display order of controls in the report with the arrow buttons found on the right of table.
  11. If the query associated with the report contains at least one numeric item, you have the ability to perform calculations these items. Specify the calculation performed for each item (sum, average, ...). Two types of calculations are available:
    • general calculation: a Calculated control will be created in the End of document block.
    • calculation on break: a Calculated control will be created in the Break footer block. In the calculations on break, the result of the calculation is reinitialized after each break. To perform a calculation on break, a break must be found in the report currently created.
  12. Depending on the type of report currently created, indicate the specific options.
    Type of reportSpecific options
    Report on formForm image, printing the form image, ...
    Options presented in Report on form
    Label reportFormat of labels, number of identical copies, ...
    Options presented in Label report
  13. Specify the format of sheet on which the report will be printed. The report is printed in A4 format by default.
    Remark: By default, the report controls are displayed in a single column. To create a multi-column report, simply specify the desired number of columns in the "Format" tab of the report description window.
  14. Select the skin template of the report if necessary.
  15. Type the name and title of the report (name of ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
    WINDEV You can also specify whether the report can be modified by the end user in "Reports & Queries".
  16. Validate the report creation.
  17. The report editor automatically proposes to change the report format if the following conditions are fulfilled:
    • the report currently created includes a table.
    • the report format does not allow to display all table columns.
  18. Specify (if necessary) the mode for reducing the report size:
    • Versions 19 and later
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
      New in version 19
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
      Print the report on several pages. In this case, the end user will have to group the pages. For more details, see Multi-page print.
    • Use the landscape mode.
    • Reduce the report size. Caution: according to the reduction percentage, the printed report may become unreadable.
  19. The report currently created is displayed in the report editor.

Using an item of the embedded query from a code of the report

To access an item of the embedded query from the code of a report, report controls or report blocks, use the following syntax:
MaSource.MaRubrique
Report on query with parameters
An independent query or an embedded query can accept parameters. In this case, one or more selection conditions depend on a parameter during the execution of the query. This parameter can correspond to the value of an edit control found a window.
For example, to print the invoice for customer X, all you have to do is create a report based on a query with parameters. In this query, the parameter will be the customer name for example. Therefore, the value of the parameter must be specified before the report is printed:
  • during the test of the report based on a query with parameters, a window allows you to type the query parameters.
  • At runtime, the query parameters must be specified using function iInitReportQuery (before using function iPrintReport).

Important

If the query is created with Reports & Queries, there is no need to use iInitReportQuery to specify the query parameters. Indeed, when running a report on a query with parameters from Reports & Queries, a window allows you to enter the parameters of the query.
Remark: For more details, see Query with parameters.
Printing a report based on a query
To print a report based on a query, you must differentiate between two cases:
  • Report on query without parameters.
  • Report on a query with parameters
Remarks:
  • If parameters must be passed to report, these parameters must be indicated in the iPrintReport function, after the name of the report to be printed.. For more details, see Report with parameters.
  • The Property SourceName used in the report code allows you to know and change the name of the query associated with the report.

Important

In Reports & Queries, you can print a report:
  • by starting a print job ( Print ).
  • by testing the report ( Go ).
Therefore, no programming is required to print the report.
When printing a report on query with parameters, a window allows you to enter the parameters of the query.

Printing a report based on a query without parameters

To print a query without parameters, you must:
  1. Configure the report print destination:
    • WINDEV In WINDEV, with iDestination (report viewer, print in an HTML file, etc.).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • AndroidiPhone/iPad In Android and iOS, with iDestination (print in a PDF file).
    For more details, see Print modes of a report.
  2. Specify the name of the report to print with iPrintReport.
    For example:
    • WINDEV In WINDEV: to print the "RPT_Query" report:
      // Ouvrir le visualisateur de rapports
      iDestination(iViewer)
      // Impression de l'état ETAT_Requete
      iPrintReport(ETAT_Requete)
    • AndroidiPhone/iPad In Android and iOS: to print the "RPT_Query" report:
      // Paramètre la destination de l'impression
      iDestination(iPDF)
      // Impression de l'état ETAT_Requete
      iPrintReport(ETAT_Requete)
    • WEBDEV - Server code In WEBDEV: to print the "RPT_Query" report in HTML format:
      // Génère un nom de fichier unique
      NomFicUnique is string = fWebDir() + "\ETAT_Requete_" + DateSys() + TimeSys() + ".htm"
      // Paramètre la destination de l'impression
      iDestination(iHTML, NomFicUnique)
      // Imprime l'état ETAT_Requete
      iPrintReport(ETAT_Requete)
      // Extrait le nom et l'extension du fichier généré
      NomFichier is string = fExtractPath(NomFicUnique, fFileName + fExtension)
      // Envoie le fichier dans le navigateur
      FileDisplay(NomFichier)

Printing a report based on a query with parameters

To print a query with parameters, you must:
  1. Configure the report print destination:
    • WINDEV In WINDEV, with iDestination (report viewer, print in an HTML file, etc.).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • AndroidiPhone/iPad In Android and iOS, with iDestination (print in a PDF file).
    For more details, see Print modes of a report.
  2. Pass the parameters to the query with iInitReportQuery.
  3. Specify the name of the report to print with iPrintReport.
For example: The "RPT_Query" report is based on a query with parameters. The parameters expected by the query are the name and type of the company. These parameters have been entered in the window for starting the report print.
  • WINDEV WINDEV code:
    // Ouvrir le visualisateur de rapports
    iDestination(iViewer)
    // Passer les paramètres à la requête associée à l'état
    iInitReportQuery(ETAT_Requete, NomSociété, TypeSociété)
    // Imprimer la liste des sociétés
    iPrintReport(ETAT_Requete)
  • AndroidiPhone/iPad In Android and iOS:
    // Paramètre la destination de l'impression
    iDestination(iPDF)
    // Passer les paramètres à la requête associée à l'état
    iInitReportQuery(ETAT_Requete, NomSociété, TypeSociété)
    // Imprimer la liste des sociétés
    iPrintReport(ETAT_Requete)
  • WEBDEV - Server code WEBDEV code:
    // Génère un nom de fichier unique
    NomFicUnique is string = fWebDir() + "\ETAT_Requete_" + DateSys() + TimeSys() + ".htm"
    // Paramètre la destination de l'impression
    iDestination(iHTML, NomFicUnique)
    // Passe les paramètres à la requête associée à l'état
    iInitReportQuery(ETAT_Requete, NomSociété, TypeSociété)
    // Imprime l'état ETAT_Requete
    iPrintReport(ETAT_Requete)
    // Extrait le nom et l'extension du fichier généré
    NomFichier is string = fExtractPath(NomFicUnique, fFileName + fExtension)
    // Envoie le fichier dans le navigateur
    FileDisplay(NomFichier)
Remark: If some of the parameters expected by the query are not specified (value corresponding to NULL for example), the selection conditions corresponding to these parameters will be ignored.
Related Examples:
WD Reports Training (WINDEV): WD Reports
[ + ] This example presents the different methods for creating a report:

- prints based on different data sources (queries, variables, ...)
- prints based on controls (Table, Spreadsheet, PVT, ...)
- printing composite reports
- specific prints (portrait/landscape, report with watermark, report with bar code, ...)
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment