Multi-level invoice

I have the following demand from a customer for invoicing:
The customer wants to be able to group articles beneath titles and optionally have subtotals per title.
So, he would like to have for instance:
Article 1
Article 2
Total Title

Title 2
Article 1
Article 2
Total Title 2

General total

The difficulty is that it should be able to work multi-level, meaning that it should be able to handle for instance the following:

Title 1
SubTitle 1
Article 1
Article 2
Total SubTitle 1
SubTitle 2
Article 3
Article 4
Total SubTitle 2
Total Title 1

General total

The display of the totals for the subtitels should also be optional.

Would it be possible to do this in FlexCel?


Yes, FlexCel should be able to assist you to get this task done efficiently. I myself always try to find an example from Adrian, the FlexCel mastermind. I always start with the Reports Designer Guide.

Here is the link for the VCL version:

One of the sections is called Master-Detail and does reflect your use-case in my opinion. Even with direct binding to a data set this should be possible. The aggregates can either be calculated in your Excel template or in Delphi. It's going to be your choice which approach is easier with regard to your data source.

Hope this gets you started. Let us know if you need further assistance.

In addition to what @Holger_Flick said, I would like to note that there are 2 issues in your particular case.

  1. The totals/subtotals part. You can easily do this with the Subtotal function in Excel. Subtotal can be used like =SUM(), but it ignores other subtotals in the list. There is a demo on using it in FlexCel here:

  2. The dynamic nature of the report, where you can have master-detail1-detail2 or master-detail1-detail2-detail3. The reporting engine in FlexCel doesn't support dynamic "on the fly" different levels of sub-sub-sub bands, but if you know in advance the maximum level of subdetails, then that should be no problem. Say, if you know you have at maximum 5 levels, then you can do a report with 5 nested details. If the report has only 3 levels, level 4 and 5 just won't run, they will be deleted and the report will be ok. What is not really possible is to have an unbounded level of details. If that is a requirement, that would likely require using the API, not the reports.