Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Set-OfficeExcelPageSetup

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

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: Default

Examples

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 optionalpipeline: True (ByValue)
Caller-owned workbook; omission uses the enclosing Excel content block.
-FitToHeight UInt32 optional
Number of pages to fit vertically.
-FitToWidth UInt32 optional
Number of pages to fit horizontally.
-MarginBottom OfficeLength optional
Bottom page margin in PDF points.
-MarginFooter OfficeLength optional
Physical distance from the page edge to the footer.
-MarginHeader OfficeLength optional
Physical distance from the page edge to the header.
-MarginLeft OfficeLength optional
Left page margin in PDF points.
-MarginPreset ExcelMarginPreset optional
Native print-margin preset applied before explicit margin overrides.
Possible values: Normal, Narrow, Moderate, Wide
-MarginRight OfficeLength optional
Right page margin in PDF points.
-MarginTop OfficeLength optional
Top page margin in PDF points.
-NoPresetPrintTitles SwitchParameter optional
Do not apply print-title rows from the selected preset.
-NoPrintTitles SwitchParameter optional
Clears repeated print rows and columns.
-Orientation OfficePageOrientation optional
Orientation to apply.
Possible values: Portrait, Landscape
-PageOrder ExcelPageOrder optional
Multi-page print order.
Possible values: DownThenOver, OverThenDown
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Preset ExcelPrintLayoutPreset optional
Margin preset to apply.
Possible values: Worksheet, Report, Dashboard, DataTable
-PrintArea String optional
Optional print area in A1 notation.
-RepeatColumns String optional
Inclusive print-title column span, such as A:B.
-RepeatRows String optional
Inclusive print-title row span, such as 1:2.
-Scale UInt32 optional
Manual scale percentage (10-400).
-Sheet OfficeSheetSelector optional
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.