Groups and subtotals
Group rows by a field, print group headers and footers with subtotals, start each group on a new page and repeat headers.
A group collects consecutive rows with the same value. Aggregates in its header and footer cover the group; in the page footer they can cover the page; anywhere you can ask for the whole report.
"groups": [{
"by": "region", "sort": "asc", "repeatHeader": true, "keepWithRows": 2,
"header": { "height": 7, "elements": [
{ "type": "text", "x": 0, "y": 0, "w": 180, "h": 7, "text": "■ {region} ({count()}건)", "style": { "bold": true } }
] },
"footer": { "height": 7, "elements": [
{ "type": "text", "x": 0, "y": 0, "w": 140, "h": 7, "text": "{region} 소계", "style": { "align": "center" } },
{ "type": "field", "x": 140, "y": 0, "w": 40, "h": 7, "expr": "sum(amount)", "format": "#,##0", "style": { "align": "right" } }
] }
}],
"pageFooter": { "height": 7, "elements": [
{ "type": "text", "x": 0, "y": 1, "w": 180, "h": 6, "text": "이 페이지 소계 {sum(amount, 'page'):#,##0}원 · 누계 {sum(amount, 'report'):#,##0}원" }
] }| Name | Type | Description |
|---|---|---|
by | Expr | Expression that groups consecutive rows, e.g. "region". |
sort | 'asc' | 'desc' | Sort rows by the group expression first (otherwise rows keep their order). |
header / footer | Band | Printed before / after each group; aggregates cover the group. |
newPage | boolean | Each group starts on a new page. |
repeatHeader | boolean | Repeat the group header on pages where the group continues. |
keepWithRows | number | Keep the header with at least this many rows (default 1). |
resetPageNumber | boolean | Restart page / pages for each group. |