PC SOFT

WINDEV的在线文档

  • 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
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系:info@cn.windev.com
产品
WinDevWebDev-服务器代码WebDev-浏览器代码WinDev Mobile报表和查询
平台
WindowsLinuxWindows MobileWindows PhoneWindows Store appsAndroidAndroid Widget iPhone/iPad
语言
JavaPHPAjax用户代码(MCU)外部语言
数据库
HFSQLHFSQL Client/Server存储过程HF 5.5OLE DBODBC本地访问

Overview
A query allows you 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 all 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 directly (and not in the query).

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 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 "查询" pane, in the "数据库表链接" group, click "创建一个报表".

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 enables 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.Clickamong 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 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 breaks to 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:
    • enter the corresponding caption. This caption will be displayed:
      • before the item. For example:
      • in the header of the column (for the Table reports). For example:
        This caption can be modified in the report editor.
    • select the block where the control associated with the item must be printed. The positions of the different controls can be modified in the report editor. See Report blocks for more details.
  8. Modify (if necessary) the display order of the controls in the report with the arrow buttons found on the right of the 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 the chart, aspect of the chart, ...
    Options presented in Table + Chart report
    Chart reportType of the chart, aspect of the chart, ...
    Options presented in Chart report
    Report on formImage of the form, print the image of the form, ...
    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 formImage of the form, print the image of the form, ...
    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 the report.
  12. Select the skin template of the report if necessary.
  13. Enter the name and title of the report (name of the ".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 format of the report 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:
    • 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.
      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 size of the report. 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 the 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 "修改" pane, in the "报表" group, click "编辑查询". The query is displayed in the query editor.
  3. Select "File .. Export .. To an independent query".On the "首页" pane, in the "常规" group, expand "保存" 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.Clickamong 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 breaks to 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:
    • enter the corresponding caption. This caption will be displayed:
      • before the item. For example:
      • in the header of the column (for the Table reports). For example:
        This caption can be modified in the report editor.
    • select the block where the control associated with the item must be printed. The positions of the different controls can be modified in the report editor. See Report blocks for more details.
  10. Modify (if necessary) the display order of the controls in the report with the arrow buttons found on the right of the 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 the chart, aspect of the chart, ...
    Options presented in Table + Chart report
    Chart reportType of the chart, aspect of the chart, ...
    Options presented in Chart report
    Report on formImage of the form, print the image of the form, ...
    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 formImage of the form, print the image of the form, ...
    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 the report.
  14. Select the skin template of the report if necessary.
  15. Enter the name and title of the report (name of the ".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 format of the report 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:
    • 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.
      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 size of the report. 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 parameters of the query must be specified by 打印初始化报表查询 (before using 打印报表).

ImportantIf the query is created with Reports & Queries, there is no need to use 打印初始化报表查询 to specify the parameters of the query. Indeed, when running a report on 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 query with parameters.
Notes:
  • If parameters must be passed to the report, these parameters must be specified in 打印报表, after the name of the report to print. See Report with parameters for more details.
  • ..数据源名称 used in the report code allows you to find out and modify the name of the query associated with the report.

ImportantIn Reports & Queries, a report can be printed:
  • by starting a print ().
  • by running the report test (or "Code .. Run the report test").by running the report test ().
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 the report print:
  2. Specify the name of the report to print with 打印报表.
    For example:
    • WinDev In WinDev: to print the "RPT_Query" report:
      // Open the preview window
      打印预览()
      // Print the RPT_Query report
      打印报表RPT_Query

Printing a query with parameters

To print a query with parameters, you must:
  1. Configure the destination of the report print:
  2. Pass the parameters to the query with 打印初始化报表查询.
  3. Specify the name of the report to print with 打印报表.
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
打印预览()
// Pass the parameters to the query associated with the report
打印初始化报表查询RPT_QueryCompanyNameCompanyType
// Print the list of companies
打印报表RPT_Query

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.