Cmdlet
Add-OfficeExcelReportLegend
Adds a legend table that explains values or colors.
Syntax
Add-OfficeExcelReportLegend
[-CaseSensitive]
[-FirstColumnFillByValue <Hashtable>]
-Header <String[]>
[-HeaderFillColor <OfficeColor>]
-InputObject <Object[]>
[-PassThru]
[[-Title] <String>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Add a legend
$legend = @(
[pscustomobject]@{ Status = 'Ready'; Meaning = 'Validated and ready to ship' }
[pscustomobject]@{ Status = 'Review'; Meaning = 'Waiting for the owner' }
)
New-OfficeExcel -Path .\Reports\Release-Readiness.xlsx {
ExcelReportSheet 'Readiness' {
ExcelReportLegend 'Status' -Header Status, Meaning -InputObject $legend
}
}Explains the status values used in the report.
Match legend colours to the table
$legend = @(
[pscustomobject]@{ Status = 'Ready'; Meaning = 'Validated and ready to ship' }
[pscustomobject]@{ Status = 'Review'; Meaning = 'Waiting for the owner' }
[pscustomobject]@{ Status = 'Blocked'; Meaning = 'Cannot ship until a dependency is fixed' }
)
New-OfficeExcel -Path .\Reports\Release-Readiness.xlsx {
ExcelReportSheet 'Readiness' {
ExcelReportTable (Import-OfficeCsv -Path .\Data\Release-Items.csv) 'Release 2026.11'
ExcelReportLegend 'Status' -Header Status, Meaning -InputObject $legend -FirstColumnFillByValue @{ Ready = '#DCFCE7'; Review = '#FEF3C7'; Blocked = '#FEE2E2' }
}
}Colours each status in the legend the same way as the rows of the readiness table.
Parameters
- -CaseSensitive SwitchParameter
- Matches names and text using ordinal case sensitivity. Omission ignores case.
- -FirstColumnFillByValue Hashtable
- Optional first-column fill colors keyed by first-column value.
- -Header String[]
- Header text identifying the target column.
- -HeaderFillColor OfficeColor
- Optional header fill color.
- -InputObject Object[]
- Objects, dictionaries or native tabular data supplied directly or through the pipeline.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Title String
- Chart title.
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.