PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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 on query
  • Printing a query without parameter
  • Printing a query with parameters
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
A query is used to easily select records in one or more data files. A query 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 the iPhone/iPad applications.
New in version 18
iPhone/iPad This feature is now available for the iPhone/iPad applications.
iPhone/iPad This feature is now available for the 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.
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. See Report on independent query for more details.
  • 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. See Report on embedded query for more details.
  • the query is based on data coming from a connection (not available in WINDEV Mobile). See Creating a SQL query via a connection (ODBC, Native Access, ...) for more details. Note: This type of report on query is available even if no analysis is associated with the WINDEV or WEBDEV project.
Tip: In the query editor, the icon ("Query .. Create a report based on this query...") is used to automatically create a report based on the current select query.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" pane, in the "File link" group, click "Create a report".
Note: An independent query or an embedded query can accept parameters. See Report on query with parameters for more details.
The report can be easily printed from your WLanguage programs. See Printing a report on query for more details.
This help page presents:
Report on independent query

Overview

The query must be created before the report (see Creating a query for more details). 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 the elements that use this query (including the reports).

Creating a report on independent query

To create a report on independent query:
  1. Select "File .. New .. Report". The wizard for report creation starts.Click New among the quick access buttons.
    • Click "Report" in the wheel that is displayed. The window for creating a new element is displayed: click "Report" then "Report".
    • The wizard for report creation starts.
  2. Choose the layout of your report (table, form, label, ...). See The different types of reports for more details.
  3. Select (if necessary) the report template to use. A report template is used to comply with a specific page layout. See The report templates for more details.
  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. See Breaks in a report for more details.
  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. See Report blocks for more details.
  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
    Type of report: Table + ChartType of chart, aspect of chart, ...
    Options presented in Table + Chart report
    Chart reportType of chart, aspect of chart, ...
    Options presented in Chart report
    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

    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 the sheet on which the report will be printed. The report is printed in A4 format by default.
    Note: By default, the report controls are displayed in a single column. To create a multi-column report, the requested number of columns must be specified in the "Format" tab of the description window of report.
  12. Select the skin template of report if necessary.
  13. Type the name and title of report (name of ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
    WINDEV You also have the ability to 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 the 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. See Multi-page print for more details.
      New in version 19
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
    • 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.
Note: 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 (or select "Report .. Edit the query"). The query is displayed in the query editor.Select "Edit the query" from the popup menu of the report. Other solution: on the "Modification" pane, in the "Report" group, click "Edit the query". The query is displayed in the query editor.
  3. Select "File .. Export .. To an independent query". On the "Home" pane, 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. Select "File .. New .. Report". The wizard for report creation starts.Click New among the quick access buttons.
    • Click "Report" in the wheel that is displayed. The window for creating a new element is displayed: click "Report" then "Report".
    • The wizard for report creation starts.
  2. Choose the layout of your report (table, form, label, ...). See The different types of reports for more details.
  3. Select (if necessary) the report template to use. A report template is used to comply with a specific page layout. See The report templates for more details.
  4. Select the data source of the report ("From a new query").
  5. The wizard for query creation starts. Select the items used by the query.
    Note: To simplify the selection of items, these items can be displayed in alphabetical order or by associated file.
  6. Define the characteristics of the query (selection condition, group, sort, ...) by clicking 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. See Breaks in a report for more details.
  9. For each query 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. See Report blocks for more details.
  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
    Type of report: Table + ChartType of chart, aspect of chart, ...
    Options presented in Table + Chart report
    Chart reportType of chart, aspect of chart, ...
    Options presented in Chart report
    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

    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 the sheet on which the report will be printed. The report is printed in A4 format by default.
    Note: By default, the report controls are displayed in a single column. To create a multi-column report, the requested number of columns must be specified in the "Format" tab of the description window of report.
  14. Select the skin template of report if necessary.
  15. Type the name and title of report (name of ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
    WINDEV You also have the ability to 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 the 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. See Multi-page print for more details.
      New in version 19
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
      Print the report on several pages. In this case, the end user will have to group the pages. See Multi-page print for more details.
    • 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 a code of the report, report controls or report blocks, use the following syntax:
MySource.MyItem
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 name of the customer for example. Therefore, the value of the parameter must be specified before the report is printed:
  • during the test of the report on a query with parameters, a window allows you to enter the parameters of the query.
  • at run time, the query parameters must be specified by iInitReportQuery (before using 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.
Note: See Query with parameters for more details.
Printing a report on query
To print a report based on a query, you must differentiate between two cases:
  • Report on query without parameter.
  • Report on a query with parameters
Notes:
  • If parameters must be passed to the report, these parameters must be specified in iPrintReport, after the name of the report to print. See Report with parameters for more details.
  • ..SourceName used in the report code allows you to find out and modify the name of the query associated with the report.

Important

In Reports & Queries, a report can be printed:
  • by starting a print ( Print ).
  • by running the report test ( Go or "Code .. Run the report test").by running the report test ( 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 query without parameter

To print a query without parameter, you must:
  1. Configure the destination of report print:
    • WINDEV In WINDEV, with iPreview (print preview, print in an HTML file, ...).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • Windows Mobile In Windows Mobile, with iConfigure or iParameter. These functions open a dialog box allowing the user to select the default printer.
      See Print modes of report for more details.
  2. Specify the name of report to print with iPrintReport.
    For example:
    • WINDEV In WINDEV: to print the "RPT_Query" report:
      // Open the preview window
      iPreview()
      // Print the RPT_Query report
      iPrintReport(RPT_Query)
    • Windows Mobile In Windows Mobile: to print the "RPT_Query" report:
      // Select the printer
      iConfigure()
      // Print the RPT_Query report
      iPrintReport(RPT_Query)
    • WEBDEV - Server code In WEBDEV: to print the "RPT_Query" report in HTML format:
      // Generates a unique file name
      UniqueFileName is string = fWebDir() + "\RPT_Query_" + ...
      DateSys() + TimeSys() + ".htm"
      // Configures the print destination
      iDestination(iHTML, UniqueFileName)
      // Prints the RPT_Query report
      iPrintReport(RPT_Query)
      // Extracts the name and extension of the generated file
      FileName is string = fExtractPath(UniqueFileName, ...
      fFileName + fExtension)
      // Sends the file to the browser
      FileDisplay(FileName)

Printing a query with parameters

To print a query with parameters, you must:
  1. Configure the destination of report print:
    • WINDEV In WINDEV, with iPreview (print preview, print in an HTML file, ...).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • Windows Mobile In Windows Mobile, with iConfigure or iParameter. These functions open a dialog box allowing the user to select the default printer.
      See Print modes of report for more details.
  2. Pass the parameters to the query with iInitReportQuery.
  3. Specify the name of 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:
    // Open the preview window
    iPreview()
    // Pass the parameters to the query associated with the report
    iInitReportQuery(RPT_Query, CompanyName, CompanyType)
    // Print the list of companies
    iPrintReport(RPT_Query)
  • Windows Mobile Windows Mobile code:
    // Select the printer
    iConfigure()
    // Pass the parameters to the query associated with the report
    iInitReportQuery(RPT_Query, CompanyName, CompanyType)
    // Print the list of companies
    iPrintReport(RPT_Query)
  • WEBDEV - Server code WEBDEV code:
    // Generates a unique file name
    UniqueFileName is string = fWebDir() + "\RPT_Query_" + ...
    DateSys() + TimeSys() + ".htm"
    // Configures the print destination
    iDestination(iHTML, UniqueFileName)
    // Pass the parameters to the query associated with the report
    iInitReportQuery(RPT_Query, CompanyName, CompanyType)
    // Prints the RPT_Query report
    iPrintReport(RPT_Query)
    // Extracts the name and extension of the generated file
    FileName is string = fExtractPath(UniqueFileName, ...
    fFileName + fExtension)
    // Sends the file to the browser
    FileDisplay(FileName)
Note: 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 required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment