Cmdlet
Set-OfficeExcelChartLegend
Shows, hides, positions and styles the chart legend.
Syntax
Set-OfficeExcelChartLegend
[-Bold]
[-Chart] <ExcelChart>
[-Color <OfficeColor>]
[-Font <String>]
[-Hidden]
[-Italic]
[-Overlay]
[-PassThru]
[-Position <Bottom| TopRight| Left| Right| Top>]
[-Size <OfficeLength>]
[<CommonParameters>]#Parameter set:
DefaultExamples
Move the legend to the bottom
New-OfficeExcel -Path .\Reports\Helpdesk-Trend.xlsx {
ExcelSheet 'Trend' {
ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Ticket-Trend.csv) -Category Week -Value Opened, Closed -Type Line -Address A1 -PassThru | ExcelChartLegend -Position Bottom
}
}Places the legend of a line chart under the plot area.
Hide the legend of a single-series chart
New-OfficeExcel -Path .\Reports\Availability.xlsx {
ExcelSheet 'Uptime' {
$chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Site-Uptime.csv) -Category Site -Value Uptime -Address A1 -Type Column -Title 'Uptime by site' -PassThru
ExcelChartLegend -Chart $chart -Hidden
}
}Removes the legend where the chart title already names the only series.
Parameters
- -Bold SwitchParameter
- Applies bold text. An explicit false value clears bold; omission preserves the native value.
- -Chart ExcelChart
- Chart to update.
- -Color OfficeColor
- Text or rule colour expressed as a literal OfficeColor or theme role.
- -Font String
- Font family name.
- Hide or show the column.
- -Italic SwitchParameter
- Applies italic text. An explicit false value clears italic; omission preserves the native value.
- -Overlay SwitchParameter
- Overlay the legend on the chart area.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Position OfficeChartLegendPosition
- Legend position.
- Possible values:
Bottom,TopRight,Left,Right,Top - -Size OfficeLength
- Font size, interpreted as points for numbers; explicit physical units are accepted.
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.