Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelPageBreak

Aliases: ExcelPageBreak
Module
PSWriteOffice
Aliases
ExcelPageBreak
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
PSWriteOffice.Models.Excel.ExcelPageBreakInfo

Adds manual print page breaks to an open worksheet.

Syntax

Add-OfficeExcelPageBreak
[-Column <Int32[]>]
[-Document <ExcelDocument>]
[-PassThru]
[-Row <Int32[]>]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]
#
Parameter set: Default

Examples

Separate report sections when printing.

ExcelSheet 'Data' { ExcelPageBreak -Row 25,50 -Column 8 }

Break before a row

Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
    ExcelSheet 'Servers' {
        ExcelPageBreak -Row 41
    }
}

Starts a new printed page at row 41.

Print each site on its own page

$sites = Import-OfficeExcel -Path .\Reports\Inventory.xlsx -Sheet Servers
$firstRows = @()
$rowNumber = 2
foreach ($group in $sites | Group-Object Site) {
    if ($rowNumber -gt 2) { $firstRows += $rowNumber }
    $rowNumber += $group.Count
}
Open-OfficeExcel -Path .\Reports\Inventory.xlsx {
    ExcelSheet 'Servers' {
        ExcelPageBreak -Row $firstRows
    }
}

Adds a page break above the first row of each site block so every site starts on a new page.

Parameters

-Column Int32[] optional
One-based columns after which printing starts a new page.
-Document ExcelDocument optionalpipeline: True (ByValue)
Gets or sets an explicit live document; omission uses the enclosing content block.
-PassThru SwitchParameter optional
Emit the worksheet's page-break snapshots after adding the selected breaks.
-Row Int32[] optional
One-based rows after which printing starts a new page.
-Sheet OfficeSheetSelector optionalaliases: WorksheetName
Worksheet name, one-based position or native worksheet; omission uses the current 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.

Outputs

PSWriteOffice.Models.Excel.ExcelPageBreakInfo: A manual print page-break snapshot that remains readable after its source workbook is closed.