From fb07fad5486724999472ad46ed928e92f316f1e1 Mon Sep 17 00:00:00 2001 From: Patrik Date: Wed, 30 Mar 2016 23:08:04 +0200 Subject: [PATCH] Ensure Datalabel is not null before referencing it. --- Export-Excel.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index e6eb4bf..dfa7698 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -350,8 +350,11 @@ function Export-Excel { $chart.Legend.Remove() } #$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.SetSize($chartDef.Width, $chartDef.Height)