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

Invoke-OfficeExcelTemplate

Aliases: ExcelTemplate, ExcelTemplateApply
Module
PSWriteOffice
Aliases
ExcelTemplate ExcelTemplateApply
Inputs
OfficeIMO.Excel.ExcelDocument
Outputs
System.Int32

Applies Excel template markers such as {{Name}} to one or more worksheets.

Syntax

Invoke-OfficeExcelTemplate
[-CultureName <String>]
[-MissingValueBehavior <PreserveMarker|EmptyString|Throw>]
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ThrowOnMissing]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: Context
Invoke-OfficeExcelTemplate
[-CultureName <String>]
[-MissingValueBehavior <PreserveMarker|EmptyString|Throw>]
[-PassThru]
[-Path] <String>
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ThrowOnMissing]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: Path
Invoke-OfficeExcelTemplate
[-CultureName <String>]
-Document <ExcelDocument>
[-MissingValueBehavior <PreserveMarker|EmptyString|Throw>]
[-PassThru]
[-Sheet <String>]
[-SheetIndex <Int32>]
[-ThrowOnMissing]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: Document

Examples

Fill a workbook template from a hashtable.

Invoke-OfficeExcelTemplate -Path .\Invoice.xlsx -Sheet Invoice -Value @{ Number = 'INV-001'; Total = 123.45 } -CultureName en-US

Replaces matching template markers and saves the workbook.

Parameters

-CultureName String optional
Culture name used for built-in marker format aliases such as currency and date.
-MissingValueBehavior ExcelTemplateMissingValueBehavior optional
Behavior used when a marker is not supplied by -Value.
Possible values: PreserveMarker, EmptyString, Throw
-PassThru SwitchParameter optional
Returns the number of marker replacements.
-Sheet String optional
Worksheet name to update. Defaults to the current DSL sheet or all workbook sheets.
-SheetIndex Int32 optional
Worksheet index (0-based) to update. Defaults to the current DSL sheet or all workbook sheets.
-ThrowOnMissing SwitchParameter optional
Throws when a marker is not supplied by -Value.
-Value Hashtable requiredaliases: Values
Template marker values keyed by marker name.
-Path String requiredposition: 0aliases: FilePath, InputPathsets: Path
Workbook path to update.
-Document ExcelDocument requiredpipeline: True (ByValue)sets: Document
Workbook to update outside the DSL context.

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.