2.3 · Reports & reporting (report editor)

Level 2 · Intermediate: data, queries & reports

2.3Reports & reporting (report editor)

Goal: Create reports (lists, invoices, labels) with the report editor and print or export them to PDF, with breaks and totals.
Estimated time: 11 min · self-paced reading · If you only have 5 min: read “The essentials in 30s” + the diagram.

The essentials in 30 seconds

  • Reports are the printed or exported documents produced by the application (invoices, delivery notes, lists, statistics, labels); WinDev provides a dedicated visual report editor.
  • A report is divided into blocks printed at different times: start of document, page header, body (repeated for each record), page footer, end of document.
  • Breaks are THE reporting mechanism: a grouping (by customer, month, category) creates a break start block and a break end block where the subtotals go — provided the data is sorted.

Running mini-case — Yacine produces the trading company's invoice

Yacine, a WinDev developer at an SME trading electrical equipment in Oran, must produce the management application's customer invoices. He creates a report in the report editor and links it to a data source: a query prepared beforehand (order + lines + customer), filtered and sorted. He places the columns in the body block (repeated for each line), the invoice header in the start of document block, the logo and title in the page header, then the grand total in end of document. Since invoices sometimes list several orders per customer, he sets a break per customer to obtain subtotals. Finally, he plans the PDF export for sending by e-mail and parameters (order number) to reuse the report.

Self-contained case for this section: it returns in the course, diagram, script and 48h challenge of section 2.3.

1. Documents, not code

Reports are the printed documents or exports produced by the application: invoices, delivery notes, lists, statistics, labels, statements. This is an area where WinDev is particularly strong, with a dedicated visual report editor. You draw the report, link it to a data source (a file from the analysis, a query, a variable), and WinDev handles pagination, breaks and totals.

2. The blocks of a report

The key notion is that of blocks: areas printed at different times. Start of document (once only: cover page, invoice header), page header (on each page: logo, title), body (repeated for each record — it is the heart), page footer (page number, legal mentions), end of document (grand totals, signature).

3. Breaks and export

Add the break blocks: when you group (by customer, by month, by category), a break start block introduces the group and a break end block displays its subtotals — on the imperative condition that the data is sorted on that column. Practical points: the report can be previewed, printed or exported (PDF in particular, much in demand), and you can pass it parameters (period, customer). Good practice: prepare the data via a query rather than multiplying calculations in the report.

Common misinterpretation: “A report calculates its totals all by itself; the body prints once; and you can group without sorting”. No, three mistakes. Subtotals per group are obtained through breaks, not automatically. The body block repeats for each record (it is the heart of the report); only the start of document block prints once. And a break requires the data to be sorted on the grouping column, otherwise a group reappears further down and produces wrong subtotals. Yacine therefore prepares his data via a sorted query.
The blocks of a report Each block prints at a precise time; breaks add subtotals per group. Start of documentOnce (invoice header)+Page headerEach page (logo, title)+BodyRepeated per record+End of documentGrand totals Break = grouping by customer/month + subtotals (sorted data mandatory).
Each block prints at a precise time; breaks add subtotals per group.
Text version of the diagram (SEO / screen readers / translation): 1) Yacine, a WinDev developer at an SME trading electrical equipment in Oran, learns that reports are the printed or exported documents of the application (invoices, lists, statistics, labels) and that WinDev's report editor is a real strength. 2) He remembers that a report is divided into blocks: start of document (once), page header (each page), body (repeated for each record), page footer and end of document (grand totals), and that breaks add subtotals per group if the data is sorted. 3) For his invoices, he links the report to a query, puts the lines in the body, the header in start of document, and plans the PDF export as well as an order-number parameter. Lesson: prepare the data via a query rather than multiplying calculations in the report.

🔎 Concrete example — 🔎 Concrete example — Break & PDF export

Obtain subtotals per customer then distribute: Yacine combines breaks, parameters and export.

// Preview the invoice report for a given order
iApercu("ETAT_Facture", {pNumCommande})

// Block structure
Start of document -> header (company name, contact details)
Page header       -> logo + title
Body              -> one line per item
Customer break    -> subtotal per customer (SORTED data)
End of document   -> grand total

Reading   : the body repeats per record; breaks produce the subtotals
Reflex    : prepare the data via a SORTED QUERY + plan the PDF export

Reading: the body block repeats each line, and the break per customer places the subtotals at the end of the group.

Lesson: the data must be sorted for the breaks to be correct, and the report is reusable thanks to the {pNumCommande} parameter.

Section vocabulary

Report
The printed or exported document produced by the application: invoice, delivery note, list, statistic, label.

Simple example: Yacine creates the trading company's “Customer invoice” report.

What it is not: an input window displayed on screen.

Reflex: produce a document → a report.

Report blocks
The areas printed at different times: start of document (once), page header (each page), body (per record), page footer, end of document.

Simple example: Yacine places the invoice lines in the body.

What it is not: a single unique block printed all at once.

Reflex: repeat per record → the body block.

Break (grouping)
Grouping by a value (customer, month, category): the start block introduces the group, the end block displays its subtotals.

Simple example: Yacine sets a break per customer for the subtotals.

What it is not: a simple sort without subtotals.

Reflex: subtotals per group → a break.

Data source
What the report relies on: a file from the analysis, a query (recommended) or variables.

Simple example: Yacine links the invoice to an order + lines + customer query.

What it is not: values entered by hand in the report.

Reflex: prepare the data cleanly → a query as the source.

PDF export
A report can be previewed, printed or exported — PDF being the most requested format (e-mail, archiving, distribution).

Simple example: Yacine e-mails the invoice to the customer as a PDF.

What it is not: printing only on paper, with no file to distribute.

Reflex: distribute or archive a document → PDF export.

In practice — In practice — Creating a report with totals

  1. First prepare a query providing exactly the data you want (filtered, sorted) rather than calculating everything in the report, like Yacine.
  2. Create the report on that source and place the columns in the body block (the one repeated for each record).
  3. Add the page header block (logo, title) and page footer (page number), then end of document for the grand total.
  4. Define a break (per customer, per month) to obtain subtotals per group, and plan the PDF export as well as parameters (period, customer).
You produce professional documents (invoices, lists, statistics) with groupings, subtotals and grand total, printable or exportable to PDF.

Step-by-step script — produce the invoice like Yacine (5 min)

1) Prepare an order + lines + customer query, filtered and sorted by customer. 2) Create a report and link it to that query. 3) Place the lines in the body block, the header in start of document and the grand total in end of document. 4) Set a break per customer for the subtotals. 5) Add a {pNumCommande} parameter and test the preview (iApercu), then export to PDF.

Without a sort on the grouping column, a group may reappear and distort the subtotals: sort the source.

Copy-paste template — my invoice report

Report source      : QUERY (order + lines + customer) filtered and SORTED
Start of document  : header (company name, contact details)
Page header        : logo + title
Body               : one line per item  (repeated per record)
Page footer        : page number
END of document    : GRAND TOTAL
Break (customer)   : subtotal per customer -> data MUST be SORTED
Parameter          : {pNumCommande}   Export: PDF

Customer invoice

Yacine produces the invoice with header, lines and grand total, exportable to PDF.

Restocking list

Yacine produces the list of products below the stock threshold, sorted by supplier.

Monthly statistics

Yacine groups sales by month with a break and subtotals.

Product labels

Yacine generates label sheets for the trading company's items.

✓ Best practices

  • Prepare the data via a query (filtered, sorted) rather than calculating everything in the report.
  • Place the lines in the body block and the total in end of document.
  • Plan the PDF export and parameters for reuse.

✗ Common pitfalls

  • Forgetting the sort before a break → wrong subtotals.
  • Putting the lines anywhere other than the body block.
  • Multiplying calculations in the report instead of preparing a query.

Key takeaways

  • Reports produce the application's documents (invoices, lists, statistics, labels).
  • A report is divided into blocks: start of document, page header, body (per record), page footer, end of document.
  • Breaks are the reporting mechanism: subtotals per group, provided the data is sorted.
  • Good practice: prepare the data via a query, plan parameters and PDF export.

48h challenge — apply it tomorrow

Like Yacine, create a report linked to a sorted query, place the lines in the body block and the total in end of document. Add a break per customer (or per month) to obtain subtotals, then export the report to PDF. Explain in one sentence why the data must be sorted on the grouping column.

Section exit checklist
  • I create a report linked to a query and place the right columns in the right block.
  • I know how to obtain subtotals per group with a break.
  • I know how to export a report to PDF with parameters.
Self-assessment 1-5: do I understand the role of each block in a report?Self-assessment 1-5: can I set a clean break (sorted data) and export to PDF?

Frequently asked questions

How do you obtain subtotals per group in a report?

By using breaks: you define a grouping on a column (customer, month, category), which creates a break start block and a break end block — the subtotals go in the end block. Imperative condition: the data must be sorted on that column, otherwise a group reappears further down and the subtotals become wrong.

Should totals be calculated in the report or in the source?

Prepare the data via a query (filtered, sorted, possibly with aggregates): the report then simply displays and places the subtotals at the breaks. Multiplying calculations in the report makes it more complex and less reusable; the good practice is to prepare the data beforehand.

Check your understanding

How do you obtain subtotals per group in a report?

Additional resources (optional, to go further)

Level 2 examFresh, harder questions to test what you've learned