This project has moved and is read-only. For the latest updates, please go here.

Grouping and summerizing in reports

Apr 26, 2013 at 4:21 PM
Thank you for the nice reporting tool.
I wonder if it is possible to create something similar to the reports like below?

The data is grouped in the second one. It has parent - Shipment and children ShipmentItems. So would it be possible to layout them like in the picture. If yes what would be the proper way to achieve the goal? If not should I use iTextSharp directly to create such a report?

Thank you in advance.
Apr 26, 2013 at 5:45 PM
Edited Apr 26, 2013 at 5:53 PM
PdfReport supports grouping.
Here are some examples which show how to enable grouping:
First you need to sort your data source items properly.
Then specify the grouping formula (how to determine when a new group should be started) by adding the column.Group method:
columns.AddColumn(column =>
                    // ...
                    (val1, val2) =>
                        return val1.ToString() == val2.ToString();
val1 and val2 are the current and previous values of the current cell here. If those are not equal, a new group will be started (so don't forget to sort data source items).

Also you can set GroupsPreferences:
            .MainTablePreferences(table =>
                // ...
                table.GroupsPreferences(new GroupsPreferences
                    GroupType = GroupType.HideGroupingColumns,
                    RepeatHeaderRowPerGroup = true,
                    ShowOneGroupPerPage = false,
                    SpacingBeforeAllGroupsSummary = 5f,
                    NewGroupAvailableSpacingThreshold = 170
To define custom group headers
  1. Try implementing the IPageHeader interface such as Grouping sample.
  2. or you can use html headers
  3. or try InlineProviders
May 3, 2013 at 6:30 PM
Thank you!
That really helped me.
May 6, 2013 at 4:07 PM
And what would be the best practice to create summary field for invoice like form?

Like what would be the best way to those: "Item sub-total", "Shipping cost", "Less discount" etc. fields below table? I thought I could make it using MainTableSummarySettings -> PageSummarySettings, but only one such setting could be added per page. Can this be customized or could I set more than one PageSummary setting? If not, then what would be the best way to implement this? Should I add footer to each group?
May 6, 2013 at 5:47 PM
Edited May 6, 2013 at 5:47 PM
You need to use events to add custom summaries per page, report or group.
Here you can find 2 samples about