PC SOFT

WINDEV的在线文档

  • Overview
  • Creating a report with parameters
  • Overview
  • Example
  • Printing a report with parameters
  • Example
  • Tip
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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
When printing a report, you have the ability to pass parameters to this report. The report is called "Report with parameters".

For example, your report corresponds to a mailshot sent to all the customers. The text of the mailshot is entered in a control before running this report. This text corresponds to a parameter expected by the report.

Creating a report with parameters

Overview

The creation of a report with parameters is performed in several steps:
  1. Creating a report.
  2. Modifying this report to support the parameters:
    • Retrieving the parameters in the "Opening" code of the report via the following syntax:
      PROCEDURE <ReportName>(<NameParam1>, ...
      <NameParam2>= "<DefaultValueParam2>;", ...
      ...
      <NameParamN> = "<DefaultValueParamN>")

      Reminder: Some of the parameters passed to a procedure can be optional parameters. When declaring the procedure, the optional parameters must be described in last position (on the right), with a default value preceded by the "=" sign. See Parameter of a procedure for more details.
    • Using these parameters in the report controls.
  3. Modifying (if necessary) the application in order to specify the different parameters.
  4. Printing the report while passing parameters. See Printing a report with parameters for more details.

Example

The program required to create a report with parameters is illustrated by the following example:
  • The "RPT_ParamReport" report corresponds to a mailing sent to the customers.
  • This report expects in parameter the text of the mailing entered in the "EDT_MailingText" edit control.
Implementation:
  1. Create the "RPT_ParamRpt" report ("File .. New .. Mailing report"). This report is linked to the "Customer" file of your analysis. See The reports for more details.Create the "RPT_ParamRpt" report:
    • 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.
    • In the wizard, select "Mailshot" and validate.
      This report is linked to the "Customer" file of your analysis. See The reports for more details.
  2. Customize this report.
  3. Enter the following code in the "Opening" process of the "RPT_ParamReport" report:
    // Retrieve the parameter passed to the report and
    // pass a default parameter for the report test
    过程RPT_ParamReportsText"Default value"
  4. In the Body block of this report, add the "STC_MailingText" static control used to display the text of the mailing.
  5. In the "Before printing" process of the "STC_MailingText" control, enter the following code:
    // Retrieve the mailing text
    STC_MailingTextsText
  6. In an application window, add:
    • the "EDT_MailingText" edit control allowing the user to type the text of the mailing.
    • the "BTN_Print" button used to print the report.

Printing a report with parameters
To print a report with parameters, you must:
  1. Configure the destination of the report print with 打印预览 (print preview, print in an HTML file, ...).
  2. Specify the following parameters via 打印报表:
    • the name of the report to print.
    • the parameters.
Notes:
  • If the report is based on a HFSQL view, the name of this HFSQL view must be specified in 打印报表, before the parameters. See Report on a HFSQL view for more details.
  • If the report is based on a memory zone, the name of this memory zone must be specified in 打印报表, before the parameters. See Report on a memory zone for more details.
  • If the report is bounded, the maximum and minimum values of the bounds must be specified in 打印报表, before the parameters. See Bounded report for more details.

Note: From version 19, HFSQL is the new name of HyperFileSQL.

Example

The "RPT_ParamReport" report corresponds to a mailing sent to the customers. This report expects in parameter the text of the mailing entered in the "EDT_MailingText" edit control.

The "RPT_ParamReport" report is printed during a click on the "BTN_Print" button.

In this example, the code of the "BTN_Print" button is as follows:

// Open the preview window
打印预览()
// Print the report while passing parameters
打印报表RPT_ParamReportSTC_MailingText

Tip
To run the test of a report with parameters from the report editor, a default value should be given to the parameters in the parameter declaration.

For example, to run the test of the report found in the previous example, enter the following code in the "Opening" process of the "RPT_ParamRpt" report:

// Retrieve the parameter passed to the report and
// pass a default parameter for the report test
过程RPT_ParamReportsText"Default value"