Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Test-OfficeExcelTemplate

Module
PSWriteOffice
Inputs
OfficeIMO.Excel.ExcelDocument System.String[]

Tests whether supplied values bind every template marker.

Syntax

Test-OfficeExcelTemplate
[-Document <ExcelDocument>]
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: Document
Test-OfficeExcelTemplate
[-Path] <String[]>
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: Path
Test-OfficeExcelTemplate
-LiteralPath <String[]>
[-Quiet]
-Value <Hashtable>
[<CommonParameters>]
#
Parameter set: LiteralPath

Examples

Check that values fill a template

Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value @{ Client = 'Northwind Traders'; Month = 'October 2026'; Availability = 0.9994 } -Quiet

Returns $true when the values bind every marker in the template.

Stop a report run when the template changed

$values = @{ Client = 'Northwind Traders'; Month = 'October 2026'; Availability = 0.9994 }
$report = Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value $values
$report.ToMarkdown() | Set-Content -Path .\Logs\Template-Binding.md
if (-not (Test-OfficeExcelTemplate -Path .\Templates\Service-Report.xltx -Value $values -Quiet)) {
    throw 'The service report template has markers this script does not fill. See Logs\Template-Binding.md.'
}

Writes a Markdown binding report for review and stops before generating the monthly reports if any marker is unbound.

Parameters

-Document ExcelDocument optionalpipeline: True (ByValue)sets: Document
Caller-owned workbook; omission uses the enclosing Excel content block.
-Quiet SwitchParameter optional
Returns a Boolean result instead of the native validation report.
-Value Hashtable required
Value or values consumed by the selected operation.
-Path String[] requiredposition: 0pipeline: True (ByValue)sets: Path
Workbook paths resolved with filesystem wildcard support.
-LiteralPath String[] requiredpipeline: True (ByPropertyName)aliases: FullName, PSPathsets: LiteralPath
Literal workbook paths, including FileInfo.FullName and provider PSPath.

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.