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 to the current Excel report sheet.

Syntax

Add-OfficeExcelReportLegend [-CaseSensitive] [-FirstColumnFillByValue <Hashtable>] -Header <String[]> [-HeaderFillColor <String>] -InputObject <Object[]> [-PassThru] [[-Title] <String>] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Examples

Authored help example

Add a status legend with colored first-column values.

$legendRows = @(
    [pscustomobject]@{ Status = 'Ready'; Meaning = 'Validated and ready' }
    [pscustomobject]@{ Status = 'Review'; Meaning = 'Needs owner review' }
)
New-OfficeExcel -Path .\Operations.xlsx {
    Add-OfficeExcelReportSheet -Name Summary {
        Add-OfficeExcelReportLegend -Title 'Status legend' -Header Status, Meaning -InputObject $legendRows -FirstColumnFillByValue @{ Ready = '#d9f7be'; Review = '#fff7e6' }
    }
}

Renders legend rows and applies optional fill colors keyed by the first column.

Parameters

-CaseSensitive SwitchParameter optional
Use case-sensitive matching for first-column fill values.
-FirstColumnFillByValue Hashtable optional
Optional first-column fill colors keyed by first-column value.
-Header String[] requiredaliases: Headers
Column headers.
-HeaderFillColor String optional
Optional header fill color.
-InputObject Object[] requiredaliases: Rows
Rows. Each row may be an array, enumerable, hashtable, or object.
-PassThru SwitchParameter optional
Emit the object created or changed by the command.
-Title String optionalposition: 0
Optional legend 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.