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-OfficeExcelPageSetup

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

Configures page setup options on a worksheet.

Syntax

Set-OfficeExcelPageSetup
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-PageOrder <DownThenOver|OverThenDown>]
[-PassThru]
[-Scale <UInt32>]
[<CommonParameters>]
#
Parameter set: Context
Set-OfficeExcelPageSetup
-Document <ExcelDocument>
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-PageOrder <DownThenOver|OverThenDown>]
[-PassThru]
[-Scale <UInt32>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Fit to one page wide.

ExcelSheet 'Data' { Set-OfficeExcelPageSetup -FitToWidth 1 -FitToHeight 0 }

Fits the sheet to one page wide and unlimited height.

Parameters

-FitToHeight UInt32 optional
Number of pages to fit vertically.
-FitToWidth UInt32 optional
Number of pages to fit horizontally.
-PageOrder ExcelPageOrder optional
Multi-page print order.
Possible values: DownThenOver, OverThenDown
-PassThru SwitchParameter optional
Emit the worksheet after applying settings.
-Scale UInt32 optional
Manual scale percentage (10-400).
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to operate on outside the DSL context.
-Sheet String optionalsets: Document
Worksheet name when using Document.
-SheetIndex Int32 optionalsets: Document
Worksheet index (0-based) when using Document.

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.