Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jhoneill
2018-07-05 07:18:13 +01:00
29 changed files with 166 additions and 71 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}

View File

@@ -1,11 +1,13 @@
$file = ".\conditionalTextFormatting.xlsx"
rm $file -ErrorAction Ignore
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
Get-Service |
Select Status, Name, DisplayName, ServiceName |
$file = ".\conditionalTextFormatting.xlsx"
Remove-Item $file -ErrorAction Ignore
Get-Service |
Select-Object Status, Name, DisplayName, ServiceName |
Export-Excel $file -Show -AutoSize -AutoFilter -ConditionalText $(
New-ConditionalText stop
New-ConditionalText stop
New-ConditionalText runn darkblue cyan
New-ConditionalText -ConditionalType EndsWith svc wheat green
New-ConditionalText -ConditionalType BeginsWith windows darkgreen wheat
New-ConditionalText -ConditionalType EndsWith svc wheat green
New-ConditionalText -ConditionalType BeginsWith windows darkgreen wheat
)

View File

@@ -1,15 +1,17 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$ContainsBlanks = New-ConditionalText -ConditionalType ContainsBlanks
$data = $(
New-PSItem a b c (echo p1 p2 p3)
New-PSItem
New-PSItem
New-PSItem d e f
New-PSItem
New-PSItem
New-PSItem g h i
New-PSItem
New-PSItem
New-PSItem g h i
)
$file ="c:\temp\testblanks.xlsx"
rm $file -ErrorAction Ignore
Remove-Item $file -ErrorAction Ignore
$data | Export-Excel $file -show -ConditionalText $ContainsBlanks

View File

@@ -1,4 +1,6 @@
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
$excel = Get-Process |
Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS |

View File

@@ -1,11 +1,13 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
$data = $(
New-PSItem North 111 (echo Region Amount )
New-PSItem East 111
New-PSItem East 111
New-PSItem West 122
New-PSItem South 200
@@ -14,11 +16,11 @@ $data = $(
New-PSItem SouthWest 136
New-PSItem South 127
New-PSItem NorthByNory 100
New-PSItem NothEast 110
New-PSItem Westerly 120
New-PSItem NorthByNory 100
New-PSItem NothEast 110
New-PSItem Westerly 120
New-PSItem SouthWest 118
)
)
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType AboveAverage)

View File

@@ -1,6 +1,8 @@
rm .\testExport.xlsx -ErrorAction Ignore
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
ps | where Company | select Company, Name, PM, Handles, *mem* |
Remove-Item .\testExport.xlsx -ErrorAction Ignore
Get-Process | Where-Object Company | Select-Object Company, Name, PM, Handles, *mem* |
Export-Excel .\testExport.xlsx -Show -AutoSize -AutoNameRange `
-ConditionalFormat $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,6 +1,8 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
.\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $(

View File

@@ -1,23 +1,25 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
Remove-Item $f -ErrorAction Ignore
$data = $(
New-PSItem North 111 (echo Region Amount )
New-PSItem East 11
New-PSItem West 12
New-PSItem South 1000
New-PSItem East 11
New-PSItem West 12
New-PSItem South 1000
New-PSItem NorthEast 10
New-PSItem SouthEast 14
New-PSItem SouthWest 13
New-PSItem South 12
New-PSItem NorthEast 10
New-PSItem SouthEast 14
New-PSItem SouthWest 13
New-PSItem South 12
New-PSItem NorthByNory 100
New-PSItem NothEast 110
New-PSItem Westerly 120
New-PSItem SouthWest 11
)
New-PSItem NorthByNory 100
New-PSItem NothEast 110
New-PSItem Westerly 120
New-PSItem SouthWest 11
)
$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType DuplicateValues)

View File

@@ -0,0 +1,25 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
$excel = @"
Month,New York City,Austin Texas,Portland Oregon
Jan,39,61,46
Feb,42,65,51
Mar,50,73,56
Apr,62,80,61
May,72,86,67
Jun,80,92,73
Jul,85,95,80
Aug,84,96,80
Sep,76,90,75
Oct,65,82,63
Nov,54,71,52
Dec,44,63,46
"@ | ConvertFrom-csv |
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -AutoSize -Title "Monthly Temperatures" -PassThru
$sheet = $excel.Workbook.Worksheets["Sheet1"]
Add-ConditionalFormatting -WorkSheet $sheet -Range "B1:D14" -DataBarColor CornflowerBlue
Close-ExcelPackage $excel -Show

View File

@@ -1,16 +1,17 @@
ipmo ImportExcel -Force
$f = ".\testExport.xlsx"
rm $f -ErrorAction Ignore
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
function Get-DateOffset ($days=0) {
$f = ".\testExport.xlsx"
Remove-Item $f -ErrorAction Ignore
function Get-DateOffset ($days=0) {
(Get-Date).AddDays($days).ToShortDateString()
}
$(
New-PSItem (Get-DateOffset -1) (Get-DateOffset 1) (echo Start End)
New-PSItem (Get-DateOffset) (Get-DateOffset 7)
New-PSItem (Get-DateOffset -10) (Get-DateOffset -1)
) |
New-PSItem (Get-DateOffset) (Get-DateOffset 7)
New-PSItem (Get-DateOffset -10) (Get-DateOffset -1)
) |
Export-Excel $f -Show -AutoSize -AutoNameRange -ConditionalText $(
New-ConditionalText -Range Start -ConditionalType Yesterday -ConditionalTextColor Red

View File

@@ -0,0 +1,22 @@
try {. $PSScriptRoot\..\..\LoadPSD1.ps1} catch {}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore
$excel = @"
Month,Sales
Jan,1277
Feb,1003
Mar,1105
Apr,952
May,770
Jun,621
"@ | ConvertFrom-csv |
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -PassThru
$sheet = $excel.Workbook.Worksheets["Sheet1"]
Add-ConditionalFormatting -WorkSheet $sheet -Range "B1:B7" -DataBarColor LawnGreen
Set-Format -Address $sheet.Cells["A8"] -Value "Total"
Set-Format -Address $sheet.Cells["B8"] -Formula "=Sum(Sales)"
Close-ExcelPackage $excel -Show