Ensure Datalabel is not null before referencing it.

This commit is contained in:
Patrik
2016-03-30 23:08:04 +02:00
parent 9e3edc129a
commit fb07fad548

View File

@@ -350,8 +350,11 @@ function Export-Excel {
$chart.Legend.Remove() $chart.Legend.Remove()
} }
#$chart.Datalabel.ShowLegendKey = $true #$chart.Datalabel.ShowLegendKey = $true
$chart.Datalabel.ShowCategory = $chartDef.ShowCategory
$chart.Datalabel.ShowPercent = $chartDef.ShowPercent if ($chart.Datalabel -ne $null) {
$chart.Datalabel.ShowCategory = $chartDef.ShowCategory
$chart.Datalabel.ShowPercent = $chartDef.ShowPercent
}
$chart.SetPosition($chartDef.Row, $chartDef.RowOffsetPixels,$chartDef.Column, $chartDef.ColumnOffsetPixels) $chart.SetPosition($chartDef.Row, $chartDef.RowOffsetPixels,$chartDef.Column, $chartDef.ColumnOffsetPixels)
$chart.SetSize($chartDef.Width, $chartDef.Height) $chart.SetSize($chartDef.Width, $chartDef.Height)