Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

Add-OfficeExcelReportLegend

Aliases: ExcelReportLegend
Module
PSWriteOffice
Aliases
ExcelReportLegend
Inputs
None

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: Default

Examples

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 optional
Matches names and text using ordinal case sensitivity. Omission ignores case.
-FirstColumnFillByValue Hashtable optional
Optional first-column fill colors keyed by first-column value.
-Header String[] required
Header text identifying the target column.
-HeaderFillColor OfficeColor optional
Optional header fill color.
-InputObject Object[] required
Objects, dictionaries or native tabular data supplied directly or through the pipeline.
-PassThru SwitchParameter optional
Emits the native result after the operation.
-Title String optionalposition: 0
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.