Added try catch for psd1 loading so it can be copy pasted to the console

This commit is contained in:
dfinke
2018-07-04 18:51:25 -04:00
parent a9aeca9550
commit 35553baa05
4 changed files with 26 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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}