PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Creating a report on variable
  • Printing a report on a variable
  • Printing a report on a variable
  • WINDEV and WINDEV Mobile examples
  • WEBDEV example
  • Notes
  • 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/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Report on variable (Databinding)
Overview
A report on 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.

Important

Reports & Queries cannot be used to create or modify reports on variable.
Versions 18 and later
iPhone/iPad This feature is now available for the iPhone/iPad applications.
New in version 18
iPhone/iPad This feature is now available for the iPhone/iPad applications.
iPhone/iPad This feature is now available for the iPhone/iPad applications.
Versions 21 and later
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Universal Windows 10 App This feature is now available in Universal Windows 10 App mode.
Creating a report on variable
To create a report on variable:
  1. Select "File .. New .. Report". The wizard for report creation starts. Click among 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. In the wizard, 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 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 by programming according to the break variable. This sort will be performed by Sort.
    See Breaks in a report for more details.
  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.
    Note: 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
    Type of report: Table + ChartType of chart, aspect of chart, ...
    Options presented in Table + Chart report
    Chart reportType of chart, aspect of chart, ...
    Options presented in Chart report
    Report on formForm image, printing the form image, ...
    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 formForm image, printing the form image, ...
    Options presented in Report on form
    Label reportFormat of labels, number of identical copies, ...
    Options presented 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.
    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 report.
  12. Select the skin template of report if necessary.
  13. Type the name and title of 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 the table columns.
  16. Specify (if necessary) the mode for reducing the report size:
    • Versions 19 and later
      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.
      New in version 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 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 on a variable

Printing a report on a variable

To print a report on variable, you must:
  1. Initialize the value of variable used.
  2. Sort the array if necessary (with ArraySort for example).
  3. Configure the destination of report print:
    • WINDEV In WINDEV, with iPreview (print preview, print in an HTML file, ...).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • Windows Mobile In Windows Mobile, with iConfigure or iParameter. These functions open a dialog box allowing the user to select the default printer.
      See Print modes of report for more details.
  4. Specify the name of 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 in parameter. In this case, the report is a report with parameters based on an array variable (see the following paragraph).

Important

In Reports & Queries, you can print a report:
  • by starting a print ( ).
  • by running the report test ( ).
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 the preview window
    iPreview()
    // Print the RPT_gglEvent report
    iPrintReport(RPT_gglEvent)
  • Windows Mobile Windows Mobile code:
    // Select the printer
    iConfigure()
    // 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.
The "RPT_gglEvent" report is displayed in a PDF file during a click on the "LINK_Event" link. Then, the PDF file is displayed in the browser. In this example, the server click code of the "LINK_Event" link 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)

Notes

  • ..SourceName used in the report code allows you to find out and change the name of the variable associated with the report.
  • ..DisplayedItem used in the report code allows you to find out 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. See the Reports with parameters for more details.
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 destination of report print:
    • WINDEV In WINDEV, with iPreview (print preview, print in an HTML file, ...).
    • WEBDEV - Server code In WEBDEV, with iDestination (print in an HTML file, ...).
    • WINDEV Mobile In WINDEV Mobile, with iConfigure or iParameter. These functions open a dialog box allowing the user to select the default printer.
      See Print modes of report for more details.
  4. Specify the following parameters via 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 during a click on the "Print the organizer events" button. This report expects in parameter the organizer for which the events will be listed.
WINDEV WINDEV code:
  • the click code of the "Print the organizer events" button is as follows:
    // Open the preview window
    iPreview()
    // Print the report while passing parameters
    iPrintReport(RPT_gglEvent, Organizer[1])
  • the code of the report is as follows:
    // Retrieve the parameters passed to the report
    PROCEDURE RPT_gglEvent(MyOrganizer)
Windows Mobile Windows Mobile code:
  • the click code of the "Print the organizer events" button is as follows:
    // Select the printer
    iConfigure()
    // Print the report while passing parameters
    iPrintReport(RPT_gglEvent, Organizer[1])
  • the code of the report is as follows:
    // Retrieve the parameters passed to the report
    PROCEDURE 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 in parameter the organizer for which the events will be listed.
In this example:
  • the click code of the "Print the organizer events" button is as follows:
    // Generates a unique file name
    UniqueFileName is string = fWebDir() + "\" + "gglEvent_" + ...
    DateSys() + TimeSys() + ".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
    PROCEDURE 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 required version
  • Version 15
This page is also available for…
Comments
Click [Add] to post a comment