Project

PSWriteOffice

PowerShell document automation across Word, Excel, PowerPoint, PDF, Reader, Confluence, Visio, and open text formats.

Stars 159
Forks 14
PowerShell Gallery downloads 158,661
Release v3.0.5
Language: C# Updated: 2026-09-03

API Reference

Cmdlet

Invoke-OfficeExcelTemplate

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

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

Remarks

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

Examples

Authored help example

Fill a workbook template from a hashtable.

PS>


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.

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.

Syntax

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

Parameters

CultureName String optionalposition: namedpipeline: False
Culture name used for built-in marker format aliases such as currency and date.
MissingValueBehavior ExcelTemplateMissingValueBehavior optionalposition: namedpipeline: Falsevalues: 3
Behavior used when a marker is not supplied by -Value.
Possible values: PreserveMarker, EmptyString, Throw
PassThru SwitchParameter optionalposition: namedpipeline: False
Returns the number of marker replacements.
Sheet String optionalposition: namedpipeline: False
Worksheet name to update. Defaults to the current DSL sheet or all workbook sheets.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) to update. Defaults to the current DSL sheet or all workbook sheets.
ThrowOnMissing SwitchParameter optionalposition: namedpipeline: False
Throws when a marker is not supplied by -Value.
Value Hashtable requiredposition: namedpipeline: Falsealiases: Values
Template marker values keyed by marker name.

Outputs

System.Int32

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

Parameters

CultureName String optionalposition: namedpipeline: False
Culture name used for built-in marker format aliases such as currency and date.
MissingValueBehavior ExcelTemplateMissingValueBehavior optionalposition: namedpipeline: Falsevalues: 3
Behavior used when a marker is not supplied by -Value.
Possible values: PreserveMarker, EmptyString, Throw
PassThru SwitchParameter optionalposition: namedpipeline: False
Returns the number of marker replacements.
Path String requiredposition: 0pipeline: Falsealiases: FilePath, InputPath
Workbook path to update.
Sheet String optionalposition: namedpipeline: False
Worksheet name to update. Defaults to the current DSL sheet or all workbook sheets.
SheetIndex Int32 optionalposition: namedpipeline: False
Worksheet index (0-based) to update. Defaults to the current DSL sheet or all workbook sheets.
ThrowOnMissing SwitchParameter optionalposition: namedpipeline: False
Throws when a marker is not supplied by -Value.
Value Hashtable requiredposition: namedpipeline: Falsealiases: Values
Template marker values keyed by marker name.

Outputs

System.Int32

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

Parameters

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

Outputs

System.Int32