Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

Stars 654
Forks 82
Open issues 1
Total downloads 4,320,051
Release OfficeIMO-v3.5.3
Language: C# Updated: 2026-11-03
Cmdlet

Set-OfficeExcelColumn

Aliases: ExcelColumn
Module
PSWriteOffice
Aliases
ExcelColumn
Inputs
OfficeIMO.Excel.ExcelDocument OfficeIMO.Excel.ExcelSheet

Writes values or applies column layout to a worksheet in a DSL block or through the pipeline.

Syntax

Set-OfficeExcelColumn
[-AutoFit]
[[-Column] <Int32>]
[-ColumnName <String>]
[-Document <ExcelDocument>]
[-Hidden <Boolean>]
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-StartRow <Int32>]
[-Values <Object[]>]
[-Width <Double>]
[-Worksheet <ExcelSheet>]
[<CommonParameters>]
#
Parameter set: All Parameter Sets

Examples

Populate a column and auto-fit it.

ExcelSheet 'Data' { Set-OfficeExcelColumn -Column 1 -Values 'North','South' -AutoFit }

Writes values into column A and adjusts the width.

Set a readable report column width through the worksheet pipeline.

$sheet | Set-OfficeExcelColumn -ColumnName C -Width 48

Sets column C to 48 Excel character units. Save the workbook after editing.

Unhide a column in a named worksheet.

$workbook | Set-OfficeExcelColumn -Sheet 'Review' -ColumnName C -Hidden $false -AutoFit

Uses the workbook pipeline target without an active DSL scope.

Parameters

-AutoFit SwitchParameter optional
Auto-fit the column width after updates.
-Column Int32 optionalposition: 0
1-based column index.
-ColumnName String optionalaliases: ColumnLetter, Letter
Column letter reference (e.g., A, BC).
-Document ExcelDocument optionalpipeline: True (ByValue)
Workbook to modify. Accepts pipeline input; select its worksheet with Sheet or SheetIndex.
-Hidden Boolean optional
Hide or show the column.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Sheet String optional
Worksheet name when using Document. The first worksheet is used when no selector is supplied.
-SheetIndex Int32 optional
Zero-based worksheet index when using Document.
-StartRow Int32 optional
Starting row index (1-based) for values.
-Values Object[] optional
Values to write down the column. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
-Width Double optional
Column width in Excel character units.
-Worksheet ExcelSheet optionalpipeline: True (ByValue)aliases: SheetObject
Worksheet to modify outside a DSL context.

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.