PC SOFT

WINDEV的在线文档

  • Overview
  • Using the wizard for creating a report on a text file
  • Creating a report on a text file with automatic reading of records
  • Characteristics of the text file when deploying the application
  • Programming the read operations performed on the records
  • Overview
  • Creating a report on a text file with programmed reading of records
  • Programming the reading of records
  • Runtime order of the different WLanguage processes
  • Modifying the method for reading records of a report on a text file
  • Printing a report on a text file
  • WinDev and WinDev Mobile example
文档页面当前正在翻译。对于此延迟我们深表歉意。
您可以自愿地帮助我们翻译您想要的文档段落,然后只需通过以下地址与我们联系: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本地访问

Report on a text file

Overview
In a report on a text file, the information to print is read in a file in text format or it is directly assigned into the report controls.

This type of report is convenient when the information to print is found in a text file (data exported from Excel for example).

Characteristics of a report on a text file: Each line found in the text file must correspond to a record. Each line contains various information, called items. The items are separated by a separator.

To create a report on a text file, you can:

  • use the wizard for creating a report based on a text file. The report editor automatically creates the report and reads the records. No programming is required.
  • program the read operation performed on the records. The wizard for report creation greatly simplifies the creation of reports. However, reading records in a text file requires full programming in WLanguage.
Once the report on a text file is created, you have the ability to:
  • modify the data source of the report ("Data" tab of the report description).
  • modify the method for reading the records found in the report (automatic or programmed). See "Modifying the method for reading the records found in a report on a text file" for more details.
  • add or delete Item controls linked to the text file associated with the report.

Using the wizard for creating a report on a text file

Creating a report on a text file with automatic reading of records

To create a report on a text file with automatic reading of records:
  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 ("Other (programing, text file, memory zone, HyperFileSQL view, ...)").Select the data source of the report ("Other (programing, text file, memory zone, HFSQL view, ...)").
  5. Select the data source of the report ("From a text file").
  6. Select "I want everything to be automatic".
  7. Specify the number of items found in the text file. This number corresponds to the number of information found in each record.
  8. Specify the separator that will be used to separate the record items:
    • "TAB" if the separator corresponds to a tabulation.
    • ";" if the separator corresponds to a semicolon.
    • ":" if the separator corresponds to a colon.
    • ...
  9. Select the text file containing the records.
    Notes:
    • The captions of the items must not be specified in this text file. For example:
    • When deploying an application containing a report based on a text file with automatic reading of records, some rules must be complied with. See "Characteristics of the text file when deploying the application" for more details.
  10. For each text file 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.
  11. Modify (if necessary) the display order of the controls in the report with the arrow buttons found on the right of the table.
  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 details in Table + Chart report
    Chart reportType of the chart, aspect of the chart, ...
    Options presented in details 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 details 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.

Characteristics of the text file when deploying the application

When deploying an application containing a report based on a text file, the following cases may occur:
  • If the text file is supplied with the application, we recommend that you include this text file in the application library.
    Caution: The content of this file cannot be modified on the end-user computer.
  • If the content of the text file might be modified on the end-user computer, when printing the report, the text file will be sought on the end-user computer according to the following order:
    1. in the libraries associated with the application and loaded into memory upon report printing.
    2. in the directory specified during report creation.
    3. in the current directory.
    4. in the application's setup directory.
  • If the text file specified when creating the report differs from the one used by the end user (different name and path), the user will have to select the file via a file picker. Once the text file is selected, the following operations can be performed:
    • send the name and path of the text file selected by the user into a variable.
    • modify the data source of the report with ..数据源名称.

Programming the read operations performed on the records

Overview

To create a report based on a text file while programming the read operations performed on the records, two steps are required:
  1. Creating the report with the creation wizard.
  2. Programming the reading of records.

Creating a report on a text file with programmed reading of records

To create a report on a text file with programmed reading of records:
  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 ("Other (programing, text file, memory zone, HyperFileSQL view, ...)").Select the data source of the report ("Other (programing, text file, memory zone, HFSQL view, ...)").
  5. Select the data source of the report ("From a text file").
  6. Select "I want to program the reading of my file".
  7. If the report currently created:
    • includes a table (Table report or Table + Chart report):
      • specify the number of columns found in the table.
      • for each column, specify the caption and type of the printed value.
      • modify (if necessary) the order of the different columns.
    • is a report on form, you must specify the options specific to the form (image of the form, print of the form image, ...). These options are presented in Report on form.
    • is a Label report, you must specify the options specific to the labels (format of labels, number of identical copies, ...). These options are presented in Label report.
        • is a Chart report, you must specify the options specific to the chart (type of chart, aspect of the chart, ...). These options are presented in Chart report.
        • is a Table + Chart report, you must specify the options specific to the chart (type of chart, aspect of the chart, ...). These options are presented in Table + Chart report.
  8. 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.
  9. Select the skin template of the report if necessary.
  10. 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".
  11. Validate the report creation.
  12. The report editor automatically proposes to change the format of the report and/or to reduce the table if the following conditions are fulfilled:
    • the report format does not allow to display all the table columns.
    • the report currently created includes a table.
  13. 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.
  14. The report currently created is displayed in the report editor.

Programming the reading of records

The programming required for reading the records is illustrated in the following example.
The information to be printed is contained in the .TXT product file. Each line in the file corresponds to a record. The data is displayed in the item controls. The different items are separated by tabulations ("TAB").

The following method is used to program the reading of records:
  1. Open the text file in the "Report opening" process (文件打开).
    Note: The captions of the items must not be specified in this text file.
    全局
    gfsLine字符串型""
    gfnFileID整数型0 // Identifier of the text file
    局部
    sTextFile字符串型文件当前目录()+"\Reports\Product.txt"
    gfnFileID文件打开sTextFile文件打开.
    如果gfnFileID=-1,那么
    错误错误信息())
    打印关闭报表() // Stop the report process
    结束
  2. In the "Report read" code:
    • Read each line of the text file (文件读一行).
    • Check whether the end of file was reached. The following values are returned according to the case:
      • : end of file not reached (step 3 is run).
      • : end of file reached (step 4 run).
        // Extract the data from the file and display it in the report
        gfsLine文件读一行gfnFileID
        // End of file reached?
        如果gfsLine定界符或者gfsLine"",那么
        发送回
        否则
        发送回
        结束
  3. The "Pre-print of BODY block" code is used to manage the file records:
    • Extract the different items from the current record (提取字符串).
    • Assign the extracted values into the report controls.
      nPrice整数型0
      nPrice提取字符串gfsLine4TAB
      // Initialize the table columns
      ITEM_Reference提取字符串gfsLine2TAB
      description的rubrique提取字符串gfsLine3TAB
      ITEM_PricenPrice
      ITEM_BarCode提取字符串gfsLine5TAB
      ITEM_Family提取字符串gfsLine6TAB
  4. The "Report closing" code is used to close the text file when the end of this file is reached (文件关闭).
    // Close the file
    文件关闭gfnFileID

Runtime order of the different WLanguage processes

The runtime order of the different WLanguage processes used to read the records are presented in the following table:
Runtime order of the report processesProgramming required for reading the text file
1. Opening the reportOpen the text file (文件打开).
2. Reading the reportRead each line of the text file (文件读一行) and manage the end of the text file.
3. Pre-print of Body blockExtract the different items from the current record (提取字符串) and assign their values into the report controls.
4. Closing the reportClose the text file (文件关闭).

Modifying the method for reading records of a report on a text file
Once the report on a text file is created, you have the ability to modify the method used for reading the records (automatic or programmed read operation).

This method is described in the "Data" tab of the report description.

To switch from an automatic read operation to a programmed read operation:

  1. Display the description window of the report by using one of the following methods:
    • "Report description" from the popup menu of the report.
    • "Report .. Report description".on the "修改" pane, click the group iconof the "报表" group.
  2. Display the "Data" tab of the report description.
  3. Check "I want too program the reading of my file".
  4. Program the reading of records. See "Programming the reading of records" for more details.
To switch from a programmed read operation to an automatic read operation:
  1. Display the description window of the report by using one of the following methods:
    • "Report description" from the popup menu of the report.
    • "Report .. Report description".on the "修改" pane, click the group iconof the "报表" group.
  2. Display the "Data" tab of the report description.
  3. Check "All automatic".
  4. Specify the number of items found in the text file.
  5. Specify the separator that will be used to separate the different items:
    • "TAB" if the separator corresponds to a tabulation.
    • ";" if the separator corresponds to a semicolon.
    • ":" if the separator corresponds to a colon.
    • ...
  6. Select the text file containing the records.
    Notes:
    • The captions of the items must not be specified in this text file. For example:
    • When deploying an application containing a report based on a text file with automatic reading of records, some rules must be complied with. See "Characteristics of the text file when deploying the application" for more details.
  7. Delete all the code lines specific to the reading of records.

Printing a report on a text file
Printing a report based on a text file is identical regardless of the method used to read the records (automatic or programmed). All you have to do is:
  1. Configure the destination of the report print:
  2. Specify the name of the report to print with 打印报表.
Notes:
  • If additional parameters must be passed to the report, these parameters must be specified in 打印报表, after the name of the report to print.
  • ..数据源名称 used in the report code allows you to find out and change the name of the text file associated with the report (if the records are automatically read).

ImportantIn Reports & Queries, a report can be printed:
  • by starting a print ().
  • by running the report test ().
Therefore, no programming is required to print the report.

WinDevWindows

WinDev and WinDev Mobile example

The "RPT_Customer" report is based on the "Customer.TXT" text file. This text file contains the characteristics of the customers.

The "RPT_Customer" report is printed during a click on the "BTN_Customer" button.

In this example, the click code of "BTN_Customer" is as follows:

WinDev WinDev code:

// Open the preview window
打印预览()
// Print the RPT_Customer report
打印报表RPT_Customer