Cmdlet
Set-OfficeExcelColumn
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 SetsExamples
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 48Sets 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 -AutoFitUses the workbook pipeline target without an active DSL scope.
Parameters
- -AutoFit SwitchParameter
- Auto-fit the column width after updates.
- -Column Int32
- 1-based column index.
- -ColumnName String
- Column letter reference (e.g., A, BC).
- -Document ExcelDocument
- Workbook to modify. Accepts pipeline input; select its worksheet with Sheet or SheetIndex.
- Hide or show the column.
- -PassThru SwitchParameter
- Emit the object created or changed by the command.
- -Sheet String
- Worksheet name when using Document. The first worksheet is used when no selector is supplied.
- -SheetIndex Int32
- Zero-based worksheet index when using Document.
- -StartRow Int32
- Starting row index (1-based) for values.
- -Values Object[]
- Values to write down the column. Numeric, Boolean, and date values retain their native Excel types; strings remain text.
- -Width Double
- Column width in Excel character units.
- -Worksheet ExcelSheet
- 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.