ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Report editor / Programming a report
  • Overview
  • "Opening" event of the report
  • Execution of the event
  • Password of the data file used as source for the report
  • Initializing variables
  • Usage example
  • Event "Reading data"
  • Execution of the event
  • Reports based on a text file
  • Usage example
  • Event "Filtering (taking the record into account?)"
  • Execution of the event
  • Using the Filter event
  • Usage example
  • "Closing" event of the report
  • Execution of the event
  • Usage example
  • Event "Before printing the report again"
  • Execution of the event
  • Usage example
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
Overview
The following events are associated to reports (order of appearance in the code editor):
Several events are associated with the reports. These events are run when printing the report.
To know the execution order of these events, see Sequence of events associated with reports.
"Opening" event of the report

Execution of the event

The "Opening" event of the report is run when starting the report print.
Reminder: When starting a report (including during a test), the events are run in the following order:

Password of the data file used as source for the report

If the source data file of the report is password protected, you must enter the password before opening the data file (with HPass, for example.)
If the data file was not opened before printing the report, the password can be specified in the "Opening" event of the report.
WINDEVReports and Queries

Initializing variables

When printing a report from the report viewer, the report is automatically re-run when:
  • the user changes printer.
  • the user selects one of the export options from the ribbon (Print in PDF mode, HTML, in an email, etc.).
In this case, the data printed in the report may be different from the data displayed in the report viewer.
The variables used by the report should be initialized in the "Opening" event rather than in the code of the Button control that starts the print.

Usage example

This event is used to:
  • declare the global variables of the report.
  • change the report bounds with the MinValue and MaxValue properties.
  • initialize the passwords of data files if necessary.
  • configure the destination of the print (iDestination).
  • pass parameters to the query linked to the report (iInitReportQuery).
  • retrieve the parameters passed to the report.
  • change the report data source.
Remark: iPrint must not be used in the report "Opening" event.
Event "Reading data"

Execution of the event

This event is run when browsing the records to print (in the print loop), once the record has been read.

Reports based on a text file

For reports based on a text file (with programmed reading), the event "Reading data" is used to read the records in the text file in order to print them.

Usage example

This event is used to:
  • perform block substitutions (as the next record to print is known).
  • select records.
  • perform specific calculations.
Remark: This event returns True if there are still records to print and False if there are no more records to print.
If you do not want to print a record, use the event "Filtering (taking the record into account?)".
Event "Filtering (taking the record into account?)"

Execution of the event

This event is run:
  • when the data source is initialized (reports based on a data file, view or memory area).
  • in the print loop, once the record is read (reports based on a query or on a Table control).
This event filters the records displayed in the report.

Using the Filter event

If there are lines of code in this event, they must return a value:
  • Cancel to stop reading the records (and to stop the print).
  • True to specify that the record matches the filter and that it must be printed.
  • False to specify that the record does not match the filter and that it must not be printed.

Usage example

This event is used to:
  • select records.
  • perform advanced calculations (subtotal, ...) for the reports based on data files, views or memory zones.
"Closing" event of the report

Execution of the event

This event is run once the report has been printed, just before closing the report.
This event must not contain print functions.
Remark: iCurrentFile is used to find out the name of the file generated for the report (for the exports in PDF, HTML, ...).

Usage example

This event is used to:
WINDEVReports and Queries
Event "Before printing the report again"

Execution of the event

This event is run when printing from the report viewer (direct print or export to PDF, XLS, RTF, etc.).
This event is run after the "Opening" event of the report.
If this event returns:
  • True, the re-print will be performed.
  • False, the re-print will be canceled.
Remarks:
  • iDestination used in this event allows you to find out the destination of the report (HTML, PDF, etc.).
  • iCurrentFile used in this event allows you to find out the name of the file generated for the report (for exports in PDF, HTML, etc.).

Usage example

This event is used to:
  • find out the quality of the generated PDF before the export in PDF format.
  • add a watermark.
  • ask for a password before the print or the export.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/26/2022

Send a report | Local help