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

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

Sets worksheet header and footer text and optional images.

Syntax

Set-OfficeExcelHeaderFooter
[-AlignWithMargins <Boolean>]
[-DifferentFirstPage]
[-DifferentOddEven]
[-FooterCenter <String>]
[-FooterImagePath <String>]
[-FooterImagePosition <Left|Center|Right>]
[-FooterImageUrl <String>]
[-FooterLeft <String>]
[-FooterRight <String>]
[-HeaderCenter <String>]
[-HeaderImagePath <String>]
[-HeaderImagePosition <Left|Center|Right>]
[-HeaderImageUrl <String>]
[-HeaderLeft <String>]
[-HeaderRight <String>]
[-ImageHeightPoints <Double>]
[-ImageWidthPoints <Double>]
[-PassThru]
[-ScaleWithDocument <Boolean>]
[<CommonParameters>]
#
Parameter set: Context
Set-OfficeExcelHeaderFooter
[-AlignWithMargins <Boolean>]
[-DifferentFirstPage]
[-DifferentOddEven]
-Document <ExcelDocument>
[-FooterCenter <String>]
[-FooterImagePath <String>]
[-FooterImagePosition <Left|Center|Right>]
[-FooterImageUrl <String>]
[-FooterLeft <String>]
[-FooterRight <String>]
[-HeaderCenter <String>]
[-HeaderImagePath <String>]
[-HeaderImagePosition <Left|Center|Right>]
[-HeaderImageUrl <String>]
[-HeaderLeft <String>]
[-HeaderRight <String>]
[-ImageHeightPoints <Double>]
[-ImageWidthPoints <Double>]
[-PassThru]
[-ScaleWithDocument <Boolean>]
[-Sheet <String>]
[-SheetIndex <Int32>]
[<CommonParameters>]
#
Parameter set: Document

Description

Uses OfficeIMO.Excel header/footer APIs and supports DSL or document usage.

Examples

Set a centered header with a page footer.

ExcelSheet 'Data' { Set-OfficeExcelHeaderFooter -HeaderCenter 'Demo' -FooterRight 'Page &P of &N' }

Applies header and footer text to the worksheet.

Parameters

-AlignWithMargins Boolean optional
Align header/footer with margins (default: true).
-DifferentFirstPage SwitchParameter optional
Use a different header/footer on the first page.
-DifferentOddEven SwitchParameter optional
Use different headers/footers on odd/even pages.
-FooterCenter String optional
Center footer text.
-FooterImagePath String optional
Footer image file path.
-FooterImagePosition ExcelHeaderFooterPosition optional
Footer image position.
Possible values: Left, Center, Right
-FooterImageUrl String optional
Footer image URL.
-FooterLeft String optional
Left footer text.
-FooterRight String optional
Right footer text.
-HeaderCenter String optional
Center header text.
-HeaderImagePath String optional
Header image file path.
-HeaderImagePosition ExcelHeaderFooterPosition optional
Header image position.
Possible values: Left, Center, Right
-HeaderImageUrl String optional
Header image URL.
-HeaderLeft String optional
Left header text.
-HeaderRight String optional
Right header text.
-ImageHeightPoints Double optional
Image height in points.
-ImageWidthPoints Double optional
Image width in points.
-PassThru SwitchParameter optional
Emit the worksheet after updating.
-ScaleWithDocument Boolean optional
Scale header/footer with document (default: true).
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to operate on outside the DSL context.
-Sheet String optionalsets: Document
Worksheet name when using Document.
-SheetIndex Int32 optionalsets: Document
Worksheet index (0-based) when using Document.

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.