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 <Nullable`1>] [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-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 Nullable`1 optionalposition: namedpipeline: False
Behavior used when a marker is not supplied by -Value.
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 Nullable`1 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>] -InputPath <String> [-MissingValueBehavior <Nullable`1>] [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-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.
InputPath String requiredposition: 0pipeline: Falsealiases: FilePath, Path
Workbook path to update.
MissingValueBehavior Nullable`1 optionalposition: namedpipeline: False
Behavior used when a marker is not supplied by -Value.
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 Nullable`1 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 <Nullable`1>] [-PassThru] [-Sheet <String>] [-SheetIndex <Nullable`1>] [-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 Nullable`1 optionalposition: namedpipeline: False
Behavior used when a marker is not supplied by -Value.
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 Nullable`1 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