Cmdlet
Set-OfficeExcelPageSetup
Sets orientation, margins, scaling, print area and print titles, alone or from a print preset.
Syntax
Set-OfficeExcelPageSetup
[-Document <ExcelDocument>]
[-FitToHeight <UInt32>]
[-FitToWidth <UInt32>]
[-MarginBottom <OfficeLength>]
[-MarginFooter <OfficeLength>]
[-MarginHeader <OfficeLength>]
[-MarginLeft <OfficeLength>]
[-MarginPreset <Normal| Narrow| Moderate| Wide>]
[-MarginRight <OfficeLength>]
[-MarginTop <OfficeLength>]
[-NoPresetPrintTitles]
[-NoPrintTitles]
[-Orientation <Portrait| Landscape>]
[-PageOrder <DownThenOver| OverThenDown>]
[-PassThru]
[-Preset <Worksheet| Report| Dashboard| DataTable>]
[-PrintArea <String>]
[-RepeatColumns <String>]
[-RepeatRows <String>]
[-Scale <UInt32>]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Print a sheet landscape on one page wide
Open-OfficeExcel -Path .\Reports\Q3-Sales.xlsx {
ExcelSheet 'Orders' {
ExcelPageSetup -Orientation Landscape -FitToWidth 1 -FitToHeight 0
}
}Sets landscape orientation and fits the columns to one page width.
Prepare a long list for printing
Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
ExcelSheet 'Servers' {
ExcelPageSetup -Preset DataTable -PrintArea A1:H420 -RepeatRows 1:1 -MarginPreset Narrow
}
}Starts from the data-table print preset, repeats the header row on every page and limits printing to the table area with narrow margins.
Parameters
- -Document ExcelDocument
- Caller-owned workbook; omission uses the enclosing Excel content block.
- -FitToHeight UInt32
- Number of pages to fit vertically.
- -FitToWidth UInt32
- Number of pages to fit horizontally.
- -MarginBottom OfficeLength
- Bottom page margin in PDF points.
- Physical distance from the page edge to the footer.
- -MarginHeader OfficeLength
- Physical distance from the page edge to the header.
- -MarginLeft OfficeLength
- Left page margin in PDF points.
- -MarginPreset ExcelMarginPreset
- Native print-margin preset applied before explicit margin overrides.
- Possible values:
Normal,Narrow,Moderate,Wide - -MarginRight OfficeLength
- Right page margin in PDF points.
- -MarginTop OfficeLength
- Top page margin in PDF points.
- -NoPresetPrintTitles SwitchParameter
- Do not apply print-title rows from the selected preset.
- -NoPrintTitles SwitchParameter
- Clears repeated print rows and columns.
- -Orientation OfficePageOrientation
- Orientation to apply.
- Possible values:
Portrait,Landscape - -PageOrder ExcelPageOrder
- Multi-page print order.
- Possible values:
DownThenOver,OverThenDown - -PassThru SwitchParameter
- Emits the native result after the operation.
- -Preset ExcelPrintLayoutPreset
- Margin preset to apply.
- Possible values:
Worksheet,Report,Dashboard,DataTable - -PrintArea String
- Optional print area in A1 notation.
- -RepeatColumns String
- Inclusive print-title column span, such as A:B.
- -RepeatRows String
- Inclusive print-title row span, such as 1:2.
- -Scale UInt32
- Manual scale percentage (10-400).
- -Sheet OfficeSheetSelector
- Worksheet name, one-based position or native worksheet object. Multi-sheet commands also accept wildcard names.
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.