# Set-OfficeExcelHeaderFooter

Sets worksheet header and footer text and optional images.

Project

PSWriteOffice

PowerShell document automation across OfficeIMO's document, spreadsheet, presentation, PDF, Project, Access, EPUB, invoicing, and conversion engines.

[View on GitHub](https://github.com/EvotecIT/OfficeIMO/tree/master/PowerShell/PSWriteOffice) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSWriteOffice/releases/tag/v3.0.5) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSWriteOffice/0.2.0)

Stars **727**

Forks **84**

Open issues **7**

Total downloads **5,275,783**

Release **OfficeIMO-v3.6.2**

Language: C# Updated: 2026-11-24

Cmdlet 

Aliases: ExcelHeaderFooter

**Module**

`PSWriteOffice`

**Aliases**

`ExcelHeaderFooter`

**Inputs**

`OfficeIMO.Excel.ExcelDocument`

**Source**

[SetOfficeExcelHeaderFooterCommand.cs:20](https://github.com/EvotecIT/PSWriteOffice/blob/main/Sources/PSWriteOffice/Cmdlets/Excel/SetOfficeExcelHeaderFooterCommand.cs#L20) 

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>]
```

[#](#member-3c5012899af7afb87a07de47)

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>]
```

[#](#member-8205b32113b02eed3c511c30)

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.

```powershell
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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:1EB586BD53247E5C2D3A955689A012CB8AD1432D467802B133CA6DF568C2B6ED -->
