Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelColumnGroup

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

Groups columns into a collapsible outline, or clears grouping.

Syntax

Set-OfficeExcelColumnGroup
[-Clear]
[-Collapsed]
[-Document <ExcelDocument>]
[[-EndColumn] <Object>]
[-Hidden]
[-KeepHidden]
[-OutlineLevel <Int32>]
[-PassThru]
[-Sheet <OfficeSheetSelector>]
[-StartColumn] <Object>
[-SummaryLeft]
[<CommonParameters>]
#
Parameter set: Default

Examples

Group monthly columns

Open-OfficeExcel -Path .\Reports\Budget-2027.xlsx {
    ExcelSheet 'Departments' {
        ExcelColumnGroup B M
    }
}

Groups columns B to M, the monthly figures, next to the yearly total.

Collapse quarters into their totals

Open-OfficeExcel -Path .\Reports\Forecast.xlsx {
    ExcelSheet 'Forecast' {
        ExcelColumnGroup B D -Collapsed
        ExcelColumnGroup F H -Collapsed
        ExcelColumnGroup J L -Collapsed
        ExcelColumnGroup N P -Collapsed
    }
}

Groups each quarter's three months and collapses them, so the sheet shows the quarterly totals first.

Parameters

-Clear SwitchParameter optional
Clear column grouping metadata from the target range.
-Collapsed SwitchParameter optional
Hide the grouped columns and mark the following summary column as collapsed.
-Document ExcelDocument optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-EndColumn Object optionalposition: 1
Last 1-based column in the group. Defaults to the start column.
-Hidden SwitchParameter optional
Hide the grouped columns without marking the group collapsed.
-KeepHidden SwitchParameter optional
Keep hidden columns hidden when clearing column 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.
-StartColumn Object requiredposition: 0
First 1-based column in the group.
-SummaryLeft SwitchParameter optional
Places outline summary columns to the left; explicit false places them to the right.

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.