[]
Creates subtotals for the range.
void Subtotal(int groupBy, ConsolidationFunction subtotalFunction, IEnumerable<int> totalList, bool replace = true, bool pageBreaks = false, SummaryRow summaryRowLocation = SummaryRow.Below)
Sub Subtotal(groupBy As Integer, subtotalFunction As ConsolidationFunction, totalList As IEnumerable(Of Integer), Optional replace As Boolean = True, Optional pageBreaks As Boolean = False, Optional summaryRowLocation As SummaryRow = SummaryRow.Below)
| Type | Name | Description |
|---|---|---|
| int | groupBy | The field to group by, as a one-based integer offset. |
| ConsolidationFunction | subtotalFunction | The subtotal function. |
| IEnumerable<int> | totalList | An array of 1-based field offsets, indicating the fields to which the subtotals are added. |
| bool | replace | True to replace existing subtotals. The default value is True. |
| bool | pageBreaks | True to add page breaks after each group. The default value is False. |
| SummaryRow | summaryRowLocation | Places the summary data relative to the subtotal. |
worksheet.Range["A1:B4"].Value = new object[,] {{"Region", "Amount"}, {"East", 120}, {"East", 80}, {"West", 90}};
worksheet.Range["A1:B4"].Subtotal(1, ConsolidationFunction.Sum, new int[] {2});
object subtotalLabel = worksheet.Range["A4"].Value;