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

Aliases: ExcelPrintLayout
Module
PSWriteOffice
Aliases
ExcelPrintLayout
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
OfficeIMO.Excel.ExcelSheet System.Management.Automation.PSObject

Applies a reusable worksheet print layout preset.

Syntax

Set-OfficeExcelPrintLayout
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-Margins <Normal|Narrow|Moderate|Wide>]
[-NoPresetPrintTitles]
[-Orientation <Portrait|Landscape>]
[-PageOrder <DownThenOver|OverThenDown>]
[-PassThru]
[-Preset <Worksheet|Report|Dashboard|DataTable>]
[-PrintArea <String>]
[-RepeatFirstColumn <Int32>]
[-RepeatFirstRow <Int32>]
[-RepeatLastColumn <Int32>]
[-RepeatLastRow <Int32>]
[-Scale <UInt32>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Context
Set-OfficeExcelPrintLayout
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-Margins <Normal|Narrow|Moderate|Wide>]
[-NoPresetPrintTitles]
[-Orientation <Portrait|Landscape>]
[-PageOrder <DownThenOver|OverThenDown>]
[-PassThru]
[-Path] <String>
[-Preset <Worksheet|Report|Dashboard|DataTable>]
[-PrintArea <String>]
[-RepeatFirstColumn <Int32>]
[-RepeatFirstRow <Int32>]
[-RepeatLastColumn <Int32>]
[-RepeatLastRow <Int32>]
[-Scale <UInt32>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Path
Set-OfficeExcelPrintLayout
-Document <ExcelDocument>
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-Margins <Normal|Narrow|Moderate|Wide>]
[-NoPresetPrintTitles]
[-Orientation <Portrait|Landscape>]
[-PageOrder <DownThenOver|OverThenDown>]
[-PassThru]
[-Preset <Worksheet|Report|Dashboard|DataTable>]
[-PrintArea <String>]
[-RepeatFirstColumn <Int32>]
[-RepeatFirstRow <Int32>]
[-RepeatLastColumn <Int32>]
[-RepeatLastRow <Int32>]
[-Scale <UInt32>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Examples

Apply a report print layout.

ExcelSheet 'Report' { Set-OfficeExcelPrintLayout -Preset Report -PrintArea A1:H40 }

Applies landscape orientation, narrow margins, one-page-wide scaling, and repeated header row.

Parameters

-FitToHeight UInt32 optional
Optional pages-tall fit override. Use 0 for unlimited height.
-FitToWidth UInt32 optional
Optional pages-wide fit override.
-Margins ExcelMarginPreset optional
Optional margin preset override.
Possible values: Normal, Narrow, Moderate, Wide
-NoPresetPrintTitles SwitchParameter optional
Do not apply print-title rows from the selected preset.
-Orientation OfficePageOrientation optional
Optional orientation override.
Possible values: Portrait, Landscape
-PageOrder ExcelPageOrder optional
Optional multi-page print order override.
Possible values: DownThenOver, OverThenDown
-PassThru SwitchParameter optional
Emit the worksheet after applying the layout.
-Preset ExcelPrintLayoutPreset optional
Print layout preset.
Possible values: Worksheet, Report, Dashboard, DataTable
-PrintArea String optional
Optional print area in A1 notation.
-RepeatFirstColumn Int32 optional
Optional first 1-based repeated print-title column.
-RepeatFirstRow Int32 optional
Optional first 1-based repeated print-title row.
-RepeatLastColumn Int32 optional
Optional last 1-based repeated print-title column.
-RepeatLastRow Int32 optional
Optional last 1-based repeated print-title row.
-Scale UInt32 optional
Optional manual scale percentage override.
-Sheet String optionalaliases: WorksheetName
Worksheet name. Defaults to the current sheet inside an ExcelSheet block.
-SheetIndex Int32 optional
Worksheet index when using a workbook object or path.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Workbook path to update.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to update outside the 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.