From 9aa0192ee6cadfd14a78a0c515ef58f22690e93e Mon Sep 17 00:00:00 2001 From: dfinke Date: Tue, 18 Jun 2019 10:44:07 -0400 Subject: [PATCH] Added and chart trendline example --- Examples/Charts/ChartAndTrendlines.ps1 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Examples/Charts/ChartAndTrendlines.ps1 diff --git a/Examples/Charts/ChartAndTrendlines.ps1 b/Examples/Charts/ChartAndTrendlines.ps1 new file mode 100644 index 0000000..7e2d41d --- /dev/null +++ b/Examples/Charts/ChartAndTrendlines.ps1 @@ -0,0 +1,21 @@ +# Creates a worksheet, addes a chart and then a Linear trendline + +$xlfile = "$env:TEMP\trendLine.xlsx" +Remove-Item $xlfile -ErrorAction SilentlyContinue + +$data = ConvertFrom-Csv @" +Region,Item,TotalSold +West,screws,60 +South,lemon,48 +South,apple,71 +East,screwdriver,70 +East,kiwi,32 +West,screwdriver,1 +South,melon,21 +East,apple,79 +South,apple,68 +South,avocado,73 +"@ + +$cd = New-ExcelChartDefinition -XRange Region -YRange TotalSold -ChartType ColumnClustered -ChartTrendLine Linear +$data | Export-Excel $xlfile -ExcelChartDefinition $cd -AutoNameRange -Show