- Create a report based on a memory area
- Printing a report based on a memory area
- WINDEV example
Report based on a memory area
A report based on a memory area is used to print the records stored in a memory area. The memory zone must necessarily
contain all the numbers of the records that must be printed.
Remark: This type of report is not available in WINDEV Mobile.
Characteristics of a report based on a memory area:
- a report based on a memory area is linked to the base data file of this memory area. The report is used to print the records coming from this base data file.
- the order in which the records are printed corresponds to the order of the record numbers found in the memory zone.
You can for example:
- store in a memory zone the numbers of the records selected by one or more processes.
- print the records only when the selection is performed.
The creation of a report based on a memory area is performed via the wizard for report creation.
To run the test of a report based on a memory area, you must:
- create and initialize the memory zone.
- print the report.
When the report based on a memory area 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 memory zone associated with the report.
Reports & Queries
does not allow you to create reports based on a memory area. However, you can customize the reports based on a memory area created in the standard report editor (color, font, size, etc.).
Create a report based on a memory area
To create a report based on a memory area:
- Click in the quick access buttons.
- The new element window appears: click "Report" then "Report".
- The report creation wizard starts.
- Choose the layout of your report (table, form, label, ...). For more details, see The different types of reports.
- 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.
- Select the data source of the report ("Other (programming, text file, memory area, HFSQL view, ..." option).
- Select the type of data source ("From a memory zone that was filled by programming").
- Select the base data file of the memory zone associated with the report.
- Select the sort items for the report. These items will be used to sort the data printed in the report. For more details on sorts, see Sorts in a report.
- To group the records, you have the ability to create breaks on the sort items. To create breaks, answer "Yes" to the question "Do you want to add some breaks into the report?".
The next step is used to select the sort items corresponding to the breaks. For more details on breaks, see Breaks in a report.
- Select the items displayed in the report. Only the controls linked to the items of the memory area will be filled.
For each file item displayed in the report:
- type the corresponding caption. This caption will be displayed:
- before the item. For example:
- in the column header (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 will be printed. The positions of different controls can be modified in the report editor. For more details on the different blocks and their position in a report, see Report blocks.
- Modify (if necessary) the display order of the controls in the report with the arrow buttons found on the right of the table.
- If the base data file of the memory area 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.
- Depending on the type of report currently created, indicate the specific options.
|Type of report||Specific options|
|Report based on a form||Form image, printing the form image, ...|
Options presented in detail in Report based on a form
|Label report||Format of labels, number of identical copies, ...|
Options presented in detail in Label report
- 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.
- Select the skin template of the report if necessary.
- Type the name and title of the report (name of ".WDE" file corresponding to the report). This name will be used to identify the report in your programs.
You can also specify whether the report can be modified by the end user in "Reports & Queries".
- Validate the report creation.
- 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.
- 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.
- The report currently created is displayed in the report editor.
Printing a report based on a memory area
To print a report based on a memory area:
- Create the memory area with MemCreate.
- Add records into the memory area with MemAdd and sort these records (if necessary) with MemSort.
- Configure the destination of the report print with iPreview (print preview, print in an HTML file, ...). For more details, see Print modes of a report.
- Specify the following parameters with iPrintReport:
- the name of the report to print.
- the name of the memory zone used.
- Delete the memory area with MemDeleteAll at the end of report print.
- If additional parameters must be passed to the report, these parameters must be specified in iPrintReport, after the name of the memory area. For more details, see Report with parameters.
- When used in the code of the report, the MemZoneName property allows you to get and change the name of the memory area associated with the report.
- When used in the code of the report, the SourceName property allows you to get and change the name of the base file of the memory area associated with the report.
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.
The user selects the customers to whom a promotional offer must be sent. The name of the selected customers is found in the List Box control named "Recipient".
Once all the customers have been selected, the Web user clicks the "BTN_Print" button to print the "RPT_MemZone" report.
When the "Print" Button control is clicked on:
- the memory zone named "MemZone" is created.
- the record number of each selected customer is retrieved and added to "MemZone".
- the "RPT_MemZone" report is printed.
- the memory zone named "MemZone" is deleted.
In this example, the click code of "BTN_Print" is as follows:
nIndex is int
// Create the memory area
// Browse through LIST_Recipient and initialize memory area
FOR nSubscript = 1 _TO_LIST_Recipient.Count
// Find the current record
HReadSeek(Customer, Name, LIST_Recipient[nIndex])
IF HFound(Customer) = True THEN
// Add the elements into the memory area
MemAdd("MemZone", "", HRecNum())
// Open report viewer
// Print the report
// Destroy the memory area
Training (WINDEV): WD Reports
This page is also available for…