ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Report editor / Data sources
  • Overview
  • Creating a report on a programmed data source
  • Overview
  • Creating a report on a programmed data source
  • Programming the reading of records
  • Order of execution of the different WLanguage events
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
Report based on a programmed data source
Overview
In a report on a programmed data source, the reading of the records that will be displayed in the report requires full programming in WLanguage. The data source can have any type (HFSQL file, query, text file, file from an external database, ...).
The creation of a report based on a programmed data source is performed by the wizard for report creation.
When the report based on a programmed data source is created, you can:
  • change the data source of the report ("Data" tab in the report description).
  • add or delete Item controls linked to the data source of the report.
Reports & Queries does not allow you to create reports based on a programmed data source. However, you have the ability to customize the reports on a programmed data source created in the standard report editor (color, fonts, size, ...).
Creating a report on a programmed data source

Overview

Two steps are required to create a report based on a programmed data source:
  1. Creating the report with the creation wizard.
  2. Programming the reading of records.

Creating a report on a programmed data source

To create a report on a programmed data source:
  1. Click in the quick access buttons.
    • The new element 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 the data source of the report ("Other (programing, text file, memory area, HFSQL view)"). Then, select "I program the reading of my data source".
  4. For each type of report, specify the corresponding specific options.
    Type of reportSpecific options
    Table 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.
    Report based on a formForm image, printing the form image, ...
    Options presented in detail in Report based on a form.
    Label reportFormat of labels, number of identical copies, ...
    Options presented in detail in Label report.
  5. Specify the format of sheet on which the report will be printed. The report is printed in A4 format by default.
  6. Select the skin template of the report if necessary.
  7. Enter the name and title of the report. This name (".WDE". file corresponding to the report) will be used to identify the report in your programs.
  8. Validate the report creation.
  9. If the report contains a table, the report editor automatically proposes to change the format of the report and/or to reduce the size of the table if some of the table columns cannot be printed in the report.
  10. Specify (if necessary) the mode for reducing the report size:
    • 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.
  11. The report currently created is displayed in the report editor.

Programming the reading of records

The programming required to read the records is presented in the following example:
Example:
The information to print is in the HFSQL data file named "Customer". The data is displayed in the item controls.

The following method is used to program the reading of records:
  1. Reading the first record of the "Customer" data file in the "Report opening" event (HReadFirst).
    // Read the first record of "Customer" data file 
    HReadFirst(Customer, CustomerNum)
  2. The event "Reading data" of the report is used to manage the end of the data file. The following values are returned according to the case:
    • True: end of file not reached (step 3 is run).
    • False: end of file reached (step 3 is not run).
      // End of "Customer" data file reached?
      IF HOut() = True THEN
      // Stop printing the Body block 
      RESULT False
      ELSE
      // Print the Body block and run its events
      RETURN True
      END
  3. The event "Before printing" of the Body block is used to manage the records of the data file:
    • Assigning the values of items in the report controls.
    • Reading the next record.
      // Assign the values of items in the report controls
      ITEM_Company = Customer.Company
      ITEM_Name = Customer.CustomerName
      ITEM_Address = Customer.Address
      ITEM_ZC = Customer.ZC
      ITEM_City = Customer.City

      // Read the next record 
      HReadNext(Customer)
  4. The event "After printing" of the Body block is used to manage a page break, should each page contain a single Body block.
    Remark: In the description window of the Body block, the option "Page break after the block" is not applied for a report based on a programmed data source.
    // Page break as long as records are still found 
    IF HOut() = False THEN
    iPageEnd()
    END

Order of execution of the different WLanguage events

The order in which the different WLanguage events are executed to read the records is presented in the following table:
Order of execution of report eventsProgramming required to read the data
1. Opening the reportReading the first record (HReadFirst for example).
2. Reading the report dataManaging the end of the data file.
3. Before printing the Body blockAssigning the values of items in the report controls and reading the next record (HReadNext for example).
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/07/2023

Send a report | Local help