# Add-OfficeExcelReportLegend

Adds a legend table that explains values or colors.

Cmdlet 

Aliases: ExcelReportLegend

**Module**

`PSWriteOffice`

**Aliases**

`ExcelReportLegend`

**Inputs**

`None`

**Source**

[AddOfficeExcelReportLegendCommand.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/PowerShell/PSWriteOffice/Sources/PSWriteOffice/Cmdlets/Excel/AddOfficeExcelReportLegendCommand.cs#L44) 

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>]
```

[#](#method-add-officeexcelreportlegend-switchparameter-hashtable-string-officecolor-object-switchparameter-string)

Parameter set: `Default`

## Examples

### Add a legend

```powershell
$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

```powershell
$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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

<!-- PowerForge markdown artifact sha256:EFE75B2A1BD32273C3595D10C5D67D5F0C1DA6388BF4DA15E8E2B507A0869A52 -->
