Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelRowGroup

Aliases: ExcelRowGroup
Module
PSWriteOffice
Aliases
ExcelRowGroup
Inputs
OfficeIMO.Excel.ExcelDocument

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: Default

Examples

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 optional
Clear row grouping metadata from the target range.
-Collapsed SwitchParameter optional
Hide the grouped rows and mark the following summary row as collapsed.
-Document ExcelDocument optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-EndRow Int32 optionalposition: 1
Last 1-based row in the group. Defaults to StartRow.
-Hidden SwitchParameter optional
Hide the grouped rows without marking the group collapsed.
-KeepHidden SwitchParameter optional
Keep hidden rows hidden when clearing row grouping metadata.
-OutlineLevel Int32 optional
Excel outline level from 1 through 7.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Sheet OfficeSheetSelector optional
Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
-StartRow Int32 requiredposition: 0
First 1-based row in the group.
-SummaryAbove SwitchParameter optional
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.