Skip to content

Instantly share code, notes, and snippets.

@dfinke
Last active February 22, 2019 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfinke/6b19531030b63cbaee49dd42ecab4d94 to your computer and use it in GitHub Desktop.
Save dfinke/6b19531030b63cbaee49dd42ecab4d94 to your computer and use it in GitHub Desktop.
$chart.DataLabel.ShowValue = $true - Shows the data labels in the chart
$xlfile = "$env:TEMP\datalabels.xlsx"
rm $xlfile -ErrorAction SilentlyContinue
$data = 1..20 | % {
[PSCustomObject]@{Idx=$_; Amount=Get-Random -Minimum 10 -Maximum 100}
}
$excel = $data | Export-Excel -Path $xlfile -AutoNameRange -PassThru
$chartParams = @{
Worksheet = $excel.Workbook.Worksheets["Sheet1"]
XRange = "Idx"
YRange = "Amount"
Title = "The Title"
ChartType = "ColumnClustered"
SeriesHeader = "The Data"
}
$chart = Add-ExcelChart @chartParams -PassThru
$chart.DataLabel.ShowValue = $true
Close-ExcelPackage $excel -Show
@dfinke
Copy link
Author

dfinke commented Feb 22, 2019

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment