mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 05:13:49 +00:00
Added try catch for psd1 loading so it can be copy pasted to the console
This commit is contained in:
@@ -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 `
|
$c = New-ExcelChart -Title Stats `
|
||||||
-ChartType LineMarkersStacked `
|
-ChartType LineMarkersStacked `
|
||||||
-Header "Stuff" `
|
-Header "Stuff" `
|
||||||
-XRange "Processes[Company]" `
|
-XRange "Processes[Company]" `
|
||||||
-YRange "Processes[PM]","Processes[VirtualMemorySize]"
|
-YRange "Processes[PM]","Processes[VirtualMemorySize]"
|
||||||
|
|
||||||
$data |
|
$data |
|
||||||
Export-Excel temp.xlsx -AutoSize -TableName Processes -Show -ExcelChartDefinition $c
|
Export-Excel temp.xlsx -AutoSize -TableName Processes -Show -ExcelChartDefinition $c
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
rm temp.xlsx -ErrorAction Ignore
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
Remove-Item temp.xlsx -ErrorAction Ignore
|
||||||
|
|
||||||
$data = @"
|
$data = @"
|
||||||
A,B,C,Date
|
A,B,C,Date
|
||||||
2,1,1,2016-03-29
|
2,1,1,2016-03-29
|
||||||
5,10,1,2016-03-29
|
5,10,1,2016-03-29
|
||||||
"@ | ConvertFrom-Csv
|
"@ | ConvertFrom-Csv
|
||||||
|
|
||||||
$c = New-ExcelChart -Title Impressions `
|
$c = New-ExcelChart -Title Impressions `
|
||||||
-ChartType Line -Header "Something" `
|
-ChartType Line -Header "Something" `
|
||||||
@@ -12,5 +14,5 @@ $c = New-ExcelChart -Title Impressions `
|
|||||||
-YRange @("Impressions[B]","Impressions[A]") `
|
-YRange @("Impressions[B]","Impressions[A]") `
|
||||||
-SeriesHeader 'B data','A data'
|
-SeriesHeader 'B data','A data'
|
||||||
|
|
||||||
$data |
|
$data |
|
||||||
Export-Excel temp.xlsx -AutoSize -TableName Impressions -Show -ExcelChartDefinition $c
|
Export-Excel temp.xlsx -AutoSize -TableName Impressions -Show -ExcelChartDefinition $c
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
rm *.xlsx
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
|
Remove-Item *.xlsx
|
||||||
|
|
||||||
$data = @"
|
$data = @"
|
||||||
ID,Product,Quantity,Price,Total
|
ID,Product,Quantity,Price,Total
|
||||||
12001,Nails,37,3.99,147.63
|
12001,Nails,37,3.99,147.63
|
||||||
12002,Hammer,5,12.10,60.5
|
12002,Hammer,5,12.10,60.5
|
||||||
12003,Saw,12,15.37,184.44
|
12003,Saw,12,15.37,184.44
|
||||||
12010,Drill,20,8,160
|
12010,Drill,20,8,160
|
||||||
12011,Crowbar,7,23.48,164.36
|
12011,Crowbar,7,23.48,164.36
|
||||||
"@ | ConvertFrom-Csv
|
"@ | ConvertFrom-Csv
|
||||||
|
|
||||||
$xRange = "Product"
|
$xRange = "Product"
|
||||||
|
|
||||||
$yRange="Price"; $c1 = New-ExcelChart -YRange $yRange -XRange $xRange -Title $yRange -Height 225
|
$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="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="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
|
Export-Excel -ExcelChartDefinition $c1,$c2,$c3 Tools.xlsx -Show -AutoFilter -AutoNameRange -AutoSize
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
|
||||||
|
|
||||||
function plot {
|
function plot {
|
||||||
param(
|
param(
|
||||||
$f,
|
$f,
|
||||||
@@ -7,18 +9,18 @@ function plot {
|
|||||||
|
|
||||||
$minx=[math]::Round($minx,1)
|
$minx=[math]::Round($minx,1)
|
||||||
$maxx=[math]::Round($maxx,1)
|
$maxx=[math]::Round($maxx,1)
|
||||||
|
|
||||||
$file = 'C:\temp\plot.xlsx'
|
$file = 'C:\temp\plot.xlsx'
|
||||||
rm $file -ErrorAction Ignore
|
Remove-Item $file -ErrorAction Ignore
|
||||||
|
|
||||||
$c = New-ExcelChart -XRange X -YRange Y -ChartType Line -NoLegend -Title Plot -Column 2 -ColumnOffSetPixels 35
|
$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) {
|
$(for ($i = $minx; $i -lt $maxx-.1; $i+=.1) {
|
||||||
[pscustomobject]@{
|
[pscustomobject]@{
|
||||||
X=$i.ToString("N1")
|
X=$i.ToString("N1")
|
||||||
Y=(&$f $i)
|
Y=(&$f $i)
|
||||||
}
|
}
|
||||||
}) | Export-Excel $file -Show -AutoNameRange -ExcelChartDefinition $c
|
}) | Export-Excel $file -Show -AutoNameRange -ExcelChartDefinition $c
|
||||||
}
|
}
|
||||||
|
|
||||||
function pi {[math]::pi}
|
function pi {[math]::pi}
|
||||||
|
|||||||
Reference in New Issue
Block a user