ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Editors / Report editor / Data sources
  • Overview
  • Creating a report based on a variable
  • Printing a report based on a variable
  • Printing a report based on a variable
  • WINDEV and WINDEV Mobile examples
  • WEBDEV example
  • Remarks
  • Printing a report with parameters based on a variable
  • WINDEV and WINDEV Mobile example
  • WEBDEV 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
Report based on a variable (Data binding)
Overview
A report based on a variable is used to directly print the information found in a WLanguage variable. This variable can be:
  • a variable global to the project,
  • a variable global to a window or to a page.
  • a variable global to a set of procedures.
This variable can be a simple array, a class member, a structure member or an advanced variable member.
Reports & Queries cannot be used to create or modify reports based on a variable.
Creating a report based on a variable
To create a report based on a variable:
  1. Click in the quick access buttons.
    • The new element window appears: click "Report" then "Report".
    • The report creation wizard starts.
  2. In the wizard, choose the layout of your report (table, form, label, ...). For more details, see The different types of reports.
  3. Select (if necessary) the report template to use. A report template is used to comply with a specific page layout. For more details on report templates, see Report templates.
  4. Select the data source of report ("From an existing variable").
  5. Select the array variable on which the report will be based. Only the variables global to the project or to the windows found in the current application are proposed.
  6. To group the records, you have the ability to create breaks on the array elements. To create breaks, answer "Yes" to the question "Do you want to add some breaks into the report?".
    The following plane is used to select the variables corresponding to the breaks.
    Caution: Before printing the report, the array variable must be sorted through programming according to the break variable. This sort will be performed by Sort.
    For more details on breaks, see Breaks in a report.
  7. Select the variables that must be displayed in the report. Modify (if necessary) the display order of controls in the report with the arrow buttons found on the right of the list.
  8. Select the block where each variable will be displayed.. You also have the ability to rename the control caption.
    Remark: By default, the controls associated with the variables are displayed in the Body block. By default, the control caption corresponds to the variable name. This caption can be modified in the report editor.
  9. If the variable associated with the report contains at least one numeric item, you have the ability to perform calculations on 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
    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
  11. Specify the format of sheet on which the report will be printed. The report is printed in A4 format by default.
    Remark: By default, the report controls are displayed in a single column. To create a multi-column report, simply specify the desired number of columns in the "Format" tab of the report description window.
  12. Select the skin template of the report if necessary.
  13. Type the name and title of the report (name of ".WDE" file corresponding to the report). This name will identify the report in your programs.
  14. Validate the report creation.
  15. The report editor automatically proposes to change the report format if the following conditions are fulfilled:
    • the report currently created includes a table.
    • the report format does not allow to display all table columns.
  16. 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.
  17. The report currently created is displayed in the report editor.
Printing a report based on a variable

Printing a report based on a variable

To print a report based on a variable, you must:
  1. Initialize the value of variable used.
  2. Sort the array if necessary (with ArraySort for example).
  3. Configure the report print destination:
    • WINDEV In WINDEV, with iDestination (report viewer, print in an HTML file, etc.).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, etc.).
    For more details, see Print modes of a report.
  4. Specify the name of the report to print with iPrintReport.
If necessary, additional parameters can be specified when printing a report with parameters based on a variable. For example, the name of the array variable to use can be passed as parameter. In this case, the report is a report with parameters based on an array variable (see the following paragraph).
In Reports & Queries, you can print a report:
  • by starting a print job ().
  • by testing the report ().
Therefore, no programming is required to print the report.
WINDEVWINDEV Mobile

WINDEV and WINDEV Mobile examples

The "RPT_gglEvent" report is based on the MyEvents variable (gglEvent type). This report is used to print the list of events found in a Google calendar.
The "RPT_gglEvent" report prints during a click on the "BTN_Event" button. In this example, the click code of "BTN_Event" button is as follows:
  • WINDEV WINDEV code:
    // Open report viewer
    iDestination(iViewer)
    // Print the RPT_gglEvent report
    iPrintReport(RPT_gglEvent)
WEBDEV - Server code

WEBDEV example

The "RPT_gglEvent" report is based on the MyEvents variable (gglEvent type). This report is used to print the list of events found in a Google calendar.
"RPT_gglEvent" is displayed in a PDF file when "LINK_Event" is clicked on. Then, the PDF file is displayed in the browser. In this example, the server click code of "LINK_Event" is as follows:
// Generates a unique PDF file name
UniqueFileName is string
UniqueFileName = fWebDir() + "\" + "RPT_gglEvent_" + DateSys() + TimeSys() + ".pdf"
// Configures the print destination
iDestination(iPDF, UniqueFileName)
// Prints the RPT_gglEvent report
iPrintReport(RPT_gglEvent)
// Sends the file to the browser
FileDisplay(UniqueFileName, "application/pdf")
// Deletes the file
fDelete(UniqueFileName)

Remarks

  • When used in the code of the report, the SourceName property allows you get and change the name of the variable associated with the report.
  • When used in the code of the report, the DisplayedItem property allows you to get and change the name of the variable associated with the item.

Printing a report with parameters based on a variable

To print a report with parameters, parameters must be passed to the report. For more details, see the Reports with parameters.
To print a report with parameters based on a variable, you must:
  1. Initialize the value of array variable used.
  2. Sort the array if necessary (with ArraySort for example).
  3. Configure the report print destination:
  4. Specify the following parameters with iPrintReport:
    • the name of the report to print.
    • the parameters expected by the report (in the order specified in the report).
WINDEVWINDEV Mobile

WINDEV and WINDEV Mobile example

A window lists the organizers and their events. The "RPT_gglEvent" report is printed when the Button control "Print the organizer events" is clicked on. This report expects as parameter the organizer for which the events will be listed.
WINDEV WINDEV code:
  • the click code of the Button control "Print the organizer events" is as follows:
    // Open report viewer
    iDestination(iViewer)
    // Print the report with parameters
    iPrintReport(RPT_gglEvent, Organizer[1])
  • the code of the report is as follows:
    // Retrieve the parameters passed to the report
    PROCÉDURE RPT_gglEvent(MyOrganizer)
WEBDEV - Server code

WEBDEV example

The "RPT_gglEvent" report is displayed in a PDF file during a click on the "Print the organizer events" link. Then, the PDF file is displayed in the browser. This report expects as parameter the organizer for which the events will be listed.
In this example:
  • the click code of the Button control "Print the organizer events" is as follows:
    // Generates a unique file name
    UniqueFileName is string = fWebDir() + "\" + "gglEvent_" + DateSys() + ".pdf"
    // Configures the print destination
    iDestination(iPDF, UniqueFileName)
    // Generates the report
    iPrintReport(RPT_gglEvent, MyOrganizer)
    // Sends the file to the browser
    FileDisplay(UniqueFileName, "application/pdf")
    // Deletes the file
    fDelete(UniqueFileName)
  • the code of the report is as follows:
    // Retrieve the parameters passed to the report
    PROCÉDURE RPT_gglEvent(MyOrganizer)
Related Examples:
WD Reports Training (WINDEV): WD Reports
[ + ] This example presents the different methods for creating a report:

- prints based on different data sources (queries, variables, ...)
- prints based on controls (Table, Spreadsheet, PVT, ...)
- printing composite reports
- specific prints (portrait/landscape, report with watermark, report with bar code, ...)
Minimum version required
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/30/2023

Send a report | Local help