Cmdlet
Set-OfficeExcelRowGroup
Groups rows into a collapsible outline, or clears grouping.
Syntax
Set-OfficeExcelRowGroup
[-Clear]
[-Collapsed]
[-Document <ExcelDocument>]
[[-EndRow] <Int32>]
[-Hidden]
[-KeepHidden]
[-OutlineLevel <Int32>]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-StartRow] <Int32>
[-SummaryAbove]
[<CommonParameters>]#Parameter set:
DefaultExamples
Group detail rows
Open-OfficeExcel -Path .\Reports\Budget-2027.xlsx {
ExcelSheet 'Departments' {
ExcelRowGroup 3 12
}
}Groups rows 3 to 12 so they can be collapsed under their summary row.
Collapse each region's detail
Open-OfficeExcel -Path .\Reports\Regional-Sales.xlsx {
ExcelSheet 'Detail' {
ExcelRowGroup 3 40 -Collapsed -SummaryAbove
ExcelRowGroup 42 77 -Collapsed -SummaryAbove
ExcelRowGroup 79 120 -Collapsed -SummaryAbove
}
}Groups and collapses the detail rows of each region with the summary row above them, so the sheet opens showing only the regional totals.
Parameters
- -Clear SwitchParameter
- Clear row grouping metadata from the target range.
- -Collapsed SwitchParameter
- Hide the grouped rows and mark the following summary row as collapsed.
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -EndRow Int32
- Last 1-based row in the group. Defaults to StartRow.
- Hide the grouped rows without marking the group collapsed.
- Keep hidden rows hidden when clearing row grouping metadata.
- -OutlineLevel Int32
- Excel outline level from 1 through 7.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
- -StartRow Int32
- First 1-based row in the group.
- -SummaryAbove SwitchParameter
- Places outline summary rows above detail rows; explicit false places them below.
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.