Cmdlet
Set-OfficeExcelChartDataLabel
Shows and styles chart data labels.
Syntax
Set-OfficeExcelChartDataLabel
[-Bold]
[-Chart] <ExcelChart>
[-Color <OfficeColor>]
[-FillColor <OfficeColor>]
[-Font <String>]
[-Italic]
[-LineColor <OfficeColor>]
[-LineWidth <OfficeLength>]
[-NoFill]
[-NoLine]
[-NumberFormat <String>]
[-PassThru]
[-Position <OfficeChartDataLabelPosition>]
[-ShowCategoryName]
[-ShowLegendKey]
[-ShowPercent]
[-ShowSeriesName]
[-ShowValue]
[-Size <OfficeLength>]
[-SourceLinked]
[<CommonParameters>]#Parameter set:
DefaultExamples
Show values on a chart
New-OfficeExcel -Path .\Reports\Regions.xlsx {
ExcelSheet 'Summary' {
ExcelTable (Import-OfficeCsv -Path .\Data\Region-Revenue.csv) -Name RegionSummary
ExcelChart -Table RegionSummary -Address F2 -Type Column -PassThru | ExcelChartDataLabel -ShowValue
}
}Shows each bar's value on the chart.
Label a share chart with percentages
New-OfficeExcel -Path .\Reports\Cloud-Spend.xlsx {
ExcelSheet 'Spend' {
$chart = ExcelChart -InputObject (Import-OfficeCsv -Path .\Data\Spend-By-Service.csv) -Category Service -Value Cost -Address A1 -Type Pie -Title 'Cloud spend by service' -PassThru
ExcelChartDataLabel -Chart $chart -ShowCategoryName -ShowPercent -Position OutsideEnd -NumberFormat '0%'
}
}Labels each slice of a pie chart with its category and percentage outside the slice.
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.
- -FillColor OfficeColor
- Optional label fill color. Named colors and hexadecimal values are accepted.
- -Font String
- Font family name.
- -Italic SwitchParameter
- Applies italic text. An explicit false value clears italic; omission preserves the native value.
- -LineColor OfficeColor
- Optional label line color. Named colors and hexadecimal values are accepted.
- -LineWidth OfficeLength
- Physical line width; numbers are interpreted as points.
- -NoFill SwitchParameter
- Remove label fill.
- -NoLine SwitchParameter
- Remove label border.
- -NumberFormat String
- Optional number format code.
- -PassThru SwitchParameter
- Emits the native result after the operation.
- -Position OfficeChartDataLabelPosition
- Optional data label position.
- Possible values:
BestFit,Bottom,Center,InsideBase,InsideEnd,Left,OutsideEnd,Right,Top - -ShowCategoryName SwitchParameter
- Show category names in labels.
- -ShowLegendKey SwitchParameter
- Show legend keys in labels.
- -ShowPercent SwitchParameter
- Show percentages in labels.
- -ShowSeriesName SwitchParameter
- Show series names in labels.
- -ShowValue SwitchParameter
- Show values in labels.
- -Size OfficeLength
- Font size, interpreted as points for numbers; explicit physical units are accepted.
- -SourceLinked SwitchParameter
- Keep number formatting linked to the source cells.
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.