Cmdlet
Add-OfficeExcelPageBreak
Adds manual print page breaks to an open worksheet.
Syntax
Add-OfficeExcelPageBreak
[-Column <Int32[]>]
[-Document <ExcelDocument>]
[-PassThru]
[-Row <Int32[]>]
[-Sheet <OfficeSheetSelector>]
[<CommonParameters>]#Parameter set:
DefaultExamples
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[]
- One-based columns after which printing starts a new page.
- -Document ExcelDocument
- Gets or sets an explicit live document; omission uses the enclosing content block.
- -PassThru SwitchParameter
- Emit the worksheet's page-break snapshots after adding the selected breaks.
- -Row Int32[]
- One-based rows after which printing starts a new page.
- -Sheet OfficeSheetSelector
- 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.