Cmdlet
Invoke-OfficeExcelTemplate
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:
ContextInvoke-OfficeExcelTemplate [-CultureName <String>] [-MissingValueBehavior <PreserveMarker|EmptyString|Throw>] [-PassThru] [-Path] <String> [-Sheet <String>] [-SheetIndex <Int32>] [-ThrowOnMissing] -Value <Hashtable> [<CommonParameters>]#Parameter set:
PathInvoke-OfficeExcelTemplate [-CultureName <String>] -Document <ExcelDocument> [-MissingValueBehavior <PreserveMarker|EmptyString|Throw>] [-PassThru] [-Sheet <String>] [-SheetIndex <Int32>] [-ThrowOnMissing] -Value <Hashtable> [<CommonParameters>]#Parameter set:
DocumentExamples
Fill a workbook template from a hashtable.
Invoke-OfficeExcelTemplate -Path .\Invoice.xlsx -Sheet Invoice -Value @{ Number = 'INV-001'; Total = 123.45 } -CultureName en-USReplaces matching template markers and saves the workbook.
Parameters
- -CultureName String
- Culture name used for built-in marker format aliases such as currency and date.
- -MissingValueBehavior ExcelTemplateMissingValueBehavior
- Behavior used when a marker is not supplied by -Value.
- Possible values:
PreserveMarker,EmptyString,Throw - -PassThru SwitchParameter
- Returns the number of marker replacements.
- -Sheet String
- Worksheet name to update. Defaults to the current DSL sheet or all workbook sheets.
- -SheetIndex Int32
- Worksheet index (0-based) to update. Defaults to the current DSL sheet or all workbook sheets.
- -ThrowOnMissing SwitchParameter
- Throws when a marker is not supplied by -Value.
- -Value Hashtable
- Template marker values keyed by marker name.
- -Path String
- Workbook path to update.
- -Document ExcelDocument
- 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.