Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Add-OfficeExcelSubtotalSummary

Aliases: ExcelSubtotals, ExcelSubtotalSummary
Namespace PSWriteOffice
Aliases
ExcelSubtotals ExcelSubtotalSummary
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelSubtotalResult

Adds grouped subtotal summary rows for a worksheet data range.

Remarks

Adds grouped subtotal summary rows for a worksheet data range.

Examples

Authored help example

Create subtotal rows below a grouped data range.

PS>


ExcelSheet Data { Add-OfficeExcelSubtotalSummary -GroupColumn Region -ValueColumn Sales -DataEndRow 20 }
        

Writes SUBTOTAL formulas below the data range and applies row outline metadata to each group.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.

Syntax

Add-OfficeExcelSubtotalSummary [-DataEndRow <Int32>] [-DataStartRow <Int32>] [-Function <Average>] [-GrandTotalLabel <String>] -GroupColumn <String> [-HeaderRow <Int32>] [-HideDetailRows] [-LabelSuffix <String>] [-NoGrandTotal] [-NoHeader] [-NoOutline] [-OutlineLevel <Int32>] [-PassThru] [-SummaryStartRow <Int32>] -ValueColumn <String[]> [<CommonParameters>]
#
Parameter set: Context

Parameters

DataEndRow Int32 optionalposition: namedpipeline: False
Last data row. Defaults to the last row of the used range.
DataStartRow Int32 optionalposition: namedpipeline: False
First data row. Defaults to the row after HeaderRow.
Function ExcelSubtotalFunction optionalposition: namedpipeline: Falsevalues: 6
Subtotal function.
Possible values: Average, Count, CountNonBlank, Max, Min, Sum
GrandTotalLabel String optionalposition: namedpipeline: False
Label used for the optional grand total row.
GroupColumn String requiredposition: namedpipeline: Falsealiases: By, GroupBy
Group column as a 1-based index, column letter, or header name.
HeaderRow Int32 optionalposition: namedpipeline: False
Header row that contains source labels. Defaults to the first row of the used range.
HideDetailRows SwitchParameter optionalposition: namedpipeline: False
Hide detail rows when applying outline metadata.
LabelSuffix String optionalposition: namedpipeline: False
Text appended to each group key in the subtotal label cell.
NoGrandTotal SwitchParameter optionalposition: namedpipeline: False
Skip writing a grand total row.
NoHeader SwitchParameter optionalposition: namedpipeline: False
Skip writing a summary header row.
NoOutline SwitchParameter optionalposition: namedpipeline: False
Skip applying outline metadata to detail rows.
OutlineLevel Int32 optionalposition: namedpipeline: False
Outline level used for grouped detail rows.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit OfficeIMO subtotal generation metadata.
SummaryStartRow Int32 optionalposition: namedpipeline: False
First row for the generated summary block.
ValueColumn String[] requiredposition: namedpipeline: Falsealiases: AggregateColumn, AggregateColumns, ValueColumns
Value columns as 1-based indexes, column letters, or header names.

Outputs

OfficeIMO.Excel.ExcelSubtotalResult

Add-OfficeExcelSubtotalSummary [-DataEndRow <Int32>] [-DataStartRow <Int32>] -Document <ExcelDocument> [-Function <Average>] [-GrandTotalLabel <String>] -GroupColumn <String> [-HeaderRow <Int32>] [-HideDetailRows] [-LabelSuffix <String>] [-NoGrandTotal] [-NoHeader] [-NoOutline] [-OutlineLevel <Int32>] [-PassThru] [-Sheet <String>] [-SheetIndex <Int32>] [-SummaryStartRow <Int32>] -ValueColumn <String[]> [<CommonParameters>]
#
Parameter set: Document

Parameters

DataEndRow Int32 optionalposition: namedpipeline: False
Last data row. Defaults to the last row of the used range.
DataStartRow Int32 optionalposition: namedpipeline: False
First data row. Defaults to the row after HeaderRow.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
Function ExcelSubtotalFunction optionalposition: namedpipeline: Falsevalues: 6
Subtotal function.
Possible values: Average, Count, CountNonBlank, Max, Min, Sum
GrandTotalLabel String optionalposition: namedpipeline: False
Label used for the optional grand total row.
GroupColumn String requiredposition: namedpipeline: Falsealiases: By, GroupBy
Group column as a 1-based index, column letter, or header name.
HeaderRow Int32 optionalposition: namedpipeline: False
Header row that contains source labels. Defaults to the first row of the used range.
HideDetailRows SwitchParameter optionalposition: namedpipeline: False
Hide detail rows when applying outline metadata.
LabelSuffix String optionalposition: namedpipeline: False
Text appended to each group key in the subtotal label cell.
NoGrandTotal SwitchParameter optionalposition: namedpipeline: False
Skip writing a grand total row.
NoHeader SwitchParameter optionalposition: namedpipeline: False
Skip writing a summary header row.
NoOutline SwitchParameter optionalposition: namedpipeline: False
Skip applying outline metadata to detail rows.
OutlineLevel Int32 optionalposition: namedpipeline: False
Outline level used for grouped detail rows.
PassThru SwitchParameter optionalposition: namedpipeline: False
Emit OfficeIMO subtotal generation metadata.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.
SummaryStartRow Int32 optionalposition: namedpipeline: False
First row for the generated summary block.
ValueColumn String[] requiredposition: namedpipeline: Falsealiases: AggregateColumn, AggregateColumns, ValueColumns
Value columns as 1-based indexes, column letters, or header names.

Outputs

OfficeIMO.Excel.ExcelSubtotalResult