diff --git a/Examples/Charts/MultiSeries.ps1 b/Examples/Charts/MultiSeries.ps1 index f98a0a4..cefdc91 100644 --- a/Examples/Charts/MultiSeries.ps1 +++ b/Examples/Charts/MultiSeries.ps1 @@ -1,12 +1,14 @@ -rm temp.xlsx -ErrorAction Ignore +try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} -$data = invoke-sum (ps) company handles,pm,VirtualMemorySize +Remove-Item temp.xlsx -ErrorAction Ignore + +$data = invoke-sum (Get-Process) company handles,pm,VirtualMemorySize $c = New-ExcelChart -Title Stats ` -ChartType LineMarkersStacked ` -Header "Stuff" ` -XRange "Processes[Company]" ` -YRange "Processes[PM]","Processes[VirtualMemorySize]" - -$data | + +$data | Export-Excel temp.xlsx -AutoSize -TableName Processes -Show -ExcelChartDefinition $c diff --git a/Examples/Charts/MultiSeries1.ps1 b/Examples/Charts/MultiSeries1.ps1 index e373213..d959281 100644 --- a/Examples/Charts/MultiSeries1.ps1 +++ b/Examples/Charts/MultiSeries1.ps1 @@ -1,10 +1,12 @@ -rm temp.xlsx -ErrorAction Ignore +try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} + +Remove-Item temp.xlsx -ErrorAction Ignore $data = @" A,B,C,Date 2,1,1,2016-03-29 5,10,1,2016-03-29 -"@ | ConvertFrom-Csv +"@ | ConvertFrom-Csv $c = New-ExcelChart -Title Impressions ` -ChartType Line -Header "Something" ` @@ -12,5 +14,5 @@ $c = New-ExcelChart -Title Impressions ` -YRange @("Impressions[B]","Impressions[A]") ` -SeriesHeader 'B data','A data' -$data | +$data | Export-Excel temp.xlsx -AutoSize -TableName Impressions -Show -ExcelChartDefinition $c \ No newline at end of file diff --git a/Examples/Charts/MultipleCharts.ps1 b/Examples/Charts/MultipleCharts.ps1 index 45ac050..e03160b 100644 --- a/Examples/Charts/MultipleCharts.ps1 +++ b/Examples/Charts/MultipleCharts.ps1 @@ -1,19 +1,21 @@ -rm *.xlsx +try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} + +Remove-Item *.xlsx $data = @" ID,Product,Quantity,Price,Total 12001,Nails,37,3.99,147.63 12002,Hammer,5,12.10,60.5 12003,Saw,12,15.37,184.44 -12010,Drill,20,8,160 +12010,Drill,20,8,160 12011,Crowbar,7,23.48,164.36 -"@ | ConvertFrom-Csv +"@ | ConvertFrom-Csv $xRange = "Product" $yRange="Price"; $c1 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Height 225 -$yRange="Total"; $c2 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Row 9 -Column 15 -Height 225 -$yRange="Quantity"; $c3 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Row 15 -Height 225 +$yRange="Total"; $c2 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Row 9 -Column 15 -Height 225 +$yRange="Quantity"; $c3 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Row 15 -Height 225 -$data | +$data | Export-Excel -ExcelChartDefinition $c1,$c2,$c3 Tools.xlsx -Show -AutoFilter -AutoNameRange -AutoSize diff --git a/Examples/Charts/plot.ps1 b/Examples/Charts/plot.ps1 index f4c367a..14921e0 100644 --- a/Examples/Charts/plot.ps1 +++ b/Examples/Charts/plot.ps1 @@ -1,3 +1,5 @@ +try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {} + function plot { param( $f, @@ -7,18 +9,18 @@ function plot { $minx=[math]::Round($minx,1) $maxx=[math]::Round($maxx,1) - - $file = 'C:\temp\plot.xlsx' - rm $file -ErrorAction Ignore + + $file = 'C:\temp\plot.xlsx' + Remove-Item $file -ErrorAction Ignore $c = New-ExcelChart -XRange X -YRange Y -ChartType Line -NoLegend -Title Plot -Column 2 -ColumnOffSetPixels 35 - + $(for ($i = $minx; $i -lt $maxx-.1; $i+=.1) { [pscustomobject]@{ X=$i.ToString("N1") Y=(&$f $i) } - }) | Export-Excel $file -Show -AutoNameRange -ExcelChartDefinition $c + }) | Export-Excel $file -Show -AutoNameRange -ExcelChartDefinition $c } function pi {[math]::pi}