Evotec

Project

PSWriteOffice

PSWriteOffice is an open-source PowerShell and .NET project with packages, release history, and technical documentation.

Stars 144
Forks 12
Open issues 16
PowerShell Gallery downloads 150,904
Release v0.2.0
Language: C# Updated: 2026-04-06

API Reference

Cmdlet

Invoke-OfficeExcelAutoFit

Namespace PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Object

Automatically fits Excel row heights and/or column widths.

Remarks

Targets the current worksheet context or a worksheet on a supplied document.

Examples

Authored help example

Auto-fit columns in the current DSL sheet.

PS>


ExcelSheet 'Data' { Invoke-OfficeExcelAutoFit -Columns }
        

Adjusts column widths for the active sheet.

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.

Syntax

Invoke-OfficeExcelAutoFit [-All] [-Column <Int32[]>] [-Columns] [-Row <Int32[]>] [-Rows] [<CommonParameters>]
#
Parameter set: Context

Parameters

All SwitchParameter optionalposition: namedpipeline: False
Auto-fit both rows and columns.
Column Int32[] optionalposition: namedpipeline: False
Auto-fit specific column indexes (1-based).
Columns SwitchParameter optionalposition: namedpipeline: False
Auto-fit all columns.
Row Int32[] optionalposition: namedpipeline: False
Auto-fit specific row indexes (1-based).
Rows SwitchParameter optionalposition: namedpipeline: False
Auto-fit all rows.

Outputs

System.Object

Invoke-OfficeExcelAutoFit [-All] [-Column <Int32[]>] [-Columns] -Document <ExcelDocument> [-Row <Int32[]>] [-Rows] [-Sheet <String>] [-SheetIndex <Nullable`1>] [<CommonParameters>]
#
Parameter set: Document

Parameters

All SwitchParameter optionalposition: namedpipeline: False
Auto-fit both rows and columns.
Column Int32[] optionalposition: namedpipeline: False
Auto-fit specific column indexes (1-based).
Columns SwitchParameter optionalposition: namedpipeline: False
Auto-fit all columns.
Document ExcelDocument requiredposition: namedpipeline: True (ByValue)
Workbook to operate on outside the DSL context.
Row Int32[] optionalposition: namedpipeline: False
Auto-fit specific row indexes (1-based).
Rows SwitchParameter optionalposition: namedpipeline: False
Auto-fit all rows.
Sheet String optionalposition: namedpipeline: False
Worksheet name when using Document.
SheetIndex Nullable`1 optionalposition: namedpipeline: False
Worksheet index (0-based) when using Document.

Outputs

System.Object