Standardising examples

This commit is contained in:
MikeyBronowski
2020-07-01 22:04:37 +02:00
parent 0a77a83e35
commit 8a20963577
50 changed files with 249 additions and 154 deletions

View File

@@ -1,8 +1,8 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlSourcefile = "$env:TEMP\Source.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile" Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore Remove-Item $xlSourcefile -ErrorAction Ignore
#Put some simple data in a worksheet and Get an excel package object to represent the file #Put some simple data in a worksheet and Get an excel package object to represent the file

View File

@@ -1,7 +1,8 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlSourcefile = "$env:TEMP\Source.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore Remove-Item $xlSourcefile -ErrorAction Ignore
#Put some simple data in a worksheet and Get an excel package object to represent the file #Put some simple data in a worksheet and Get an excel package object to represent the file

View File

@@ -1,7 +1,10 @@
# Creates a worksheet, addes a chart and then a Linear trendline # Creates a worksheet, addes a chart and then a Linear trendline
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:TEMP\trendLine.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $xlfile -ErrorAction SilentlyContinue $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = ConvertFrom-Csv @" $data = ConvertFrom-Csv @"
Region,Item,TotalSold Region,Item,TotalSold
@@ -18,4 +21,4 @@ South,avocado,73
"@ "@
$cd = New-ExcelChartDefinition -XRange Region -YRange TotalSold -ChartType ColumnClustered -ChartTrendLine Linear $cd = New-ExcelChartDefinition -XRange Region -YRange TotalSold -ChartType ColumnClustered -ChartTrendLine Linear
$data | Export-Excel $xlfile -ExcelChartDefinition $cd -AutoNameRange -Show $data | Export-Excel $xlSourcefile -ExcelChartDefinition $cd -AutoNameRange -Show

View File

@@ -1,6 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item temp.xlsx -ErrorAction Ignore #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = Invoke-Sum -data (Get-Process) -dimension Company -measure Handles, PM, VirtualMemorySize $data = Invoke-Sum -data (Get-Process) -dimension Company -measure Handles, PM, VirtualMemorySize
@@ -11,4 +14,4 @@ $c = New-ExcelChartDefinition -Title "ProcessStats" `
-SeriesHeader "PM","VM" -SeriesHeader "PM","VM"
$data | $data |
Export-Excel -Path temp.xlsx -AutoSize -TableName Processes -ExcelChartDefinition $c -Show Export-Excel -Path $xlSourcefile -AutoSize -TableName Processes -ExcelChartDefinition $c -Show

View File

@@ -1,6 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item temp.xlsx -ErrorAction Ignore #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = @" $data = @"
A,B,C,Date A,B,C,Date
@@ -15,5 +18,5 @@ $c = New-ExcelChartDefinition -Title Impressions `
-SeriesHeader 'B data','A data' ` -SeriesHeader 'B data','A data' `
-Row 0 -Column 0 -Row 0 -Column 0
$data | ConvertFrom-Csv | Export-Excel -path temp.xlsx -AutoSize -TableName Impressions $data | ConvertFrom-Csv | Export-Excel -path $xlSourcefile -AutoSize -TableName Impressions
Export-Excel -path temp.xlsx -worksheetName chartPage -ExcelChartDefinition $c -show Export-Excel -path $xlSourcefile -worksheetName chartPage -ExcelChartDefinition $c -show

View File

@@ -1,6 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item -Path Tools.xlsx #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = @" $data = @"
ID,Product,Quantity,Price,Total ID,Product,Quantity,Price,Total
@@ -16,4 +19,4 @@ $c2 = New-ExcelChartDefinition -YRange "Total "-XRange "Product" -Title "Total
$c3 = New-ExcelChartDefinition -YRange "Quantity"-XRange "Product" -Title "Sales volume" -NoLegend -Height 225 -Row 15 $c3 = New-ExcelChartDefinition -YRange "Quantity"-XRange "Product" -Title "Sales volume" -NoLegend -Height 225 -Row 15
$data | ConvertFrom-Csv | $data | ConvertFrom-Csv |
Export-Excel -Path "Tools.xlsx" -AutoFilter -AutoNameRange -AutoSize -ExcelChartDefinition $c1,$c2,$c3 -Show Export-Excel -Path $xlSourcefile -AutoFilter -AutoNameRange -AutoSize -ExcelChartDefinition $c1,$c2,$c3 -Show

View File

@@ -1,4 +1,6 @@
$xlfile = "$env:TEMP\visitors.xlsx" try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:TEMP\visitors.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue Remove-Item $xlfile -ErrorAction SilentlyContinue
$data = ConvertFrom-Csv @" $data = ConvertFrom-Csv @"

View File

@@ -10,8 +10,10 @@ 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' #Get rid of pre-exisiting sheet
Remove-Item $file -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -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
@@ -20,7 +22,7 @@ function plot {
X=$i.ToString("N1") X=$i.ToString("N1")
Y=(&$f $i) Y=(&$f $i)
} }
}) | Export-Excel $file -Show -AutoNameRange -LineChart -NoLegend #-ExcelChartDefinition $c }) | Export-Excel $xlSourcefile -Show -AutoNameRange -LineChart -NoLegend #-ExcelChartDefinition $c
} }
function pi {[math]::pi} function pi {[math]::pi}

View File

@@ -1,11 +1,13 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$file = "$env:temp\conditionalTextFormatting.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $file -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
Get-Service | Get-Service |
Select-Object Status, Name, DisplayName, ServiceName | Select-Object Status, Name, DisplayName, ServiceName |
Export-Excel $file -Show -AutoSize -AutoFilter -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -AutoFilter -ConditionalText $(
New-ConditionalText stop #Stop is the condition value, the rule is defaults to 'Contains text' and the default Colors are used New-ConditionalText stop #Stop is the condition value, the rule is defaults to 'Contains text' and the default Colors are used
New-ConditionalText runn darkblue cyan #runn is the condition value, the rule is defaults to 'Contains text'; the foregroundColur is darkblue and the background is cyan New-ConditionalText runn darkblue cyan #runn is the condition value, the rule is defaults to 'Contains text'; the foregroundColur is darkblue and the background is cyan
New-ConditionalText -ConditionalType EndsWith svc wheat green #the rule here is 'Ends with' and the value is 'svc' the forground is wheat and the background dark green New-ConditionalText -ConditionalType EndsWith svc wheat green #the rule here is 'Ends with' and the value is 'svc' the forground is wheat and the background dark green

View File

@@ -12,8 +12,10 @@ $data = $(
New-PSItem g h i New-PSItem g h i
) )
$file ="$env:temp\testblanks.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
Remove-Item $file -ErrorAction Ignore
#use the conditional format definition created above #use the conditional format definition created above
$data | Export-Excel $file -show -ConditionalText $ContainsBlanks $data | Export-Excel $xlSourcefile -show -ConditionalText $ContainsBlanks

View File

@@ -1,12 +1,14 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$path = "$env:temp\test.xlsx" #Get rid of pre-exisiting sheet
Remove-Item -Path $path -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
#Export processes, and get an ExcelPackage object representing the file. #Export processes, and get an ExcelPackage object representing the file.
$excel = Get-Process | $excel = Get-Process |
Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS | Select-Object -Property Name,Company,Handles,CPU,PM,NPM,WS |
Export-Excel -Path $path -ClearSheet -WorkSheetname "Processes" -PassThru Export-Excel -Path $xlSourcefile -ClearSheet -WorkSheetname "Processes" -PassThru
$sheet = $excel.Workbook.Worksheets["Processes"] $sheet = $excel.Workbook.Worksheets["Processes"]

View File

@@ -1,8 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = "$env:TEMP\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = $( $data = $(
@@ -25,6 +26,6 @@ $data = $(
# the syntax is used is Export-excel -ConditionalText (New-Conditional text <parameters>) <other parameters> # the syntax is used is Export-excel -ConditionalText (New-Conditional text <parameters>) <other parameters>
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType AboveAverage) #$data | Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType AboveAverage)
$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType BelowAverage) $data | Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType BelowAverage)
#$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType TopPercent) #$data | Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType TopPercent)

View File

@@ -1,3 +1,5 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
function Get-DateOffset { function Get-DateOffset {
param($days=0) param($days=0)

View File

@@ -1,12 +1,15 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item "$env:TEMP\testExport.xlsx" -ErrorAction Ignore #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
Get-Process | Where-Object Company | Select-Object Company, Name, PM, Handles, *mem* | Get-Process | Where-Object Company | Select-Object Company, Name, PM, Handles, *mem* |
#This example creates a 3 Icon set for the values in the "PM column, and Highlights company names (anywhere in the data) with different colors #This example creates a 3 Icon set for the values in the "PM column, and Highlights company names (anywhere in the data) with different colors
Export-Excel "$env:TEMP\testExport.xlsx" -Show -AutoSize -AutoNameRange ` Export-Excel -Path $xlSourcefile -Show -AutoSize -AutoNameRange `
-ConditionalFormat $( -ConditionalFormat $(
New-ConditionalFormattingIconSet -Range "C:C" ` New-ConditionalFormattingIconSet -Range "C:C" `
-ConditionalFormat ThreeIconSet -IconType Arrows -ConditionalFormat ThreeIconSet -IconType Arrows

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType Last7Days New-ConditionalText -ConditionalType Last7Days
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType LastMonth New-ConditionalText -ConditionalType LastMonth
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType LastWeek New-ConditionalText -ConditionalType LastWeek
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType NextMonth New-ConditionalText -ConditionalType NextMonth
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType NextWeek New-ConditionalText -ConditionalType NextWeek
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType ThisMonth New-ConditionalText -ConditionalType ThisMonth
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType ThisWeek New-ConditionalText -ConditionalType ThisWeek
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType Today New-ConditionalText -ConditionalType Today
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType Tomorrow New-ConditionalText -ConditionalType Tomorrow
) )

View File

@@ -1,10 +1,11 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
.\GenDates.ps1 | .\GenDates.ps1 |
Export-Excel $f -Show -AutoSize -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText $(
New-ConditionalText -ConditionalType Yesterday New-ConditionalText -ConditionalType Yesterday
) )

View File

@@ -1,8 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $f -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = $( $data = $(
@@ -22,4 +23,4 @@ $data = $(
New-PSItem SouthWest 11 New-PSItem SouthWest 11
) )
$data | Export-Excel $f -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType DuplicateValues) $data | Export-Excel $xlSourcefile -Show -AutoSize -ConditionalText (New-ConditionalText -ConditionalType DuplicateValues)

View File

@@ -1,6 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$excel = @" $excel = @"
Month,New York City,Austin Texas,Portland Oregon Month,New York City,Austin Texas,Portland Oregon
@@ -17,7 +20,7 @@ Oct,65,82,63
Nov,54,71,52 Nov,54,71,52
Dec,44,63,46 Dec,44,63,46
"@ | ConvertFrom-csv | "@ | ConvertFrom-csv |
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -AutoSize -Title "Monthly Temperatures" -PassThru Export-Excel -Path $xlSourcefile -WorkSheetname Sheet1 -AutoNameRange -AutoSize -Title "Monthly Temperatures" -PassThru
$sheet = $excel.Workbook.Worksheets["Sheet1"] $sheet = $excel.Workbook.Worksheets["Sheet1"]
Add-ConditionalFormatting -Worksheet $sheet -Range "B1:D14" -DataBarColor CornflowerBlue Add-ConditionalFormatting -Worksheet $sheet -Range "B1:D14" -DataBarColor CornflowerBlue

View File

@@ -1,7 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = ".\testExport.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $f -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
function Get-DateOffset ($days=0) { function Get-DateOffset ($days=0) {
(Get-Date).AddDays($days).ToShortDateString() (Get-Date).AddDays($days).ToShortDateString()
@@ -13,7 +15,7 @@ $(
New-PSItem (Get-DateOffset -10) (Get-DateOffset -1) New-PSItem (Get-DateOffset -10) (Get-DateOffset -1)
) | ) |
Export-Excel $f -Show -AutoSize -AutoNameRange -ConditionalText $( Export-Excel $xlSourcefile -Show -AutoSize -AutoNameRange -ConditionalText $(
New-ConditionalText -Range Start -ConditionalType Yesterday -ConditionalTextColor Red New-ConditionalText -Range Start -ConditionalType Yesterday -ConditionalTextColor Red
New-ConditionalText -Range End -ConditionalType Yesterday -BackgroundColor Blue -ConditionalTextColor Red New-ConditionalText -Range End -ConditionalType Yesterday -BackgroundColor Blue -ConditionalTextColor Red
) )

View File

@@ -1,6 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item -Path .\test.xlsx -ErrorAction Ignore #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$excel = @" $excel = @"
Month,Sales Month,Sales
@@ -11,7 +14,7 @@ Apr,952
May,770 May,770
Jun,621 Jun,621
"@ | ConvertFrom-csv | "@ | ConvertFrom-csv |
Export-Excel -Path .\test.xlsx -WorkSheetname Sheet1 -AutoNameRange -PassThru Export-Excel -Path $xlSourcefile -WorkSheetname Sheet1 -AutoNameRange -PassThru
$sheet = $excel.Workbook.Worksheets["Sheet1"] $sheet = $excel.Workbook.Worksheets["Sheet1"]
Add-ConditionalFormatting -Worksheet $sheet -Range "B1:B7" -DataBarColor LawnGreen Add-ConditionalFormatting -Worksheet $sheet -Range "B1:B7" -DataBarColor LawnGreen

View File

@@ -8,18 +8,22 @@ $data = $(
New-PSItem 500 New-PSItem 500
) )
$file1 = "$env:Temp\tryComparison1.xlsx" #Get rid of pre-exisiting sheet
$file2 = "$env:Temp\tryComparison2.xlsx" $xlSourcefile1 = "$env:TEMP\ImportExcelExample1.xlsx"
$xlSourcefile2 = "$env:TEMP\ImportExcelExample2.xlsx"
Remove-Item -Path $file1 -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile1"
Remove-Item -Path $file2 -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile2"
$data | Export-Excel $file1 -Show -ConditionalText $( Remove-Item $xlSourcefile1 -ErrorAction Ignore
Remove-Item $xlSourcefile2 -ErrorAction Ignore
$data | Export-Excel $xlSourcefile1 -Show -ConditionalText $(
New-ConditionalText -ConditionalType GreaterThan 300 New-ConditionalText -ConditionalType GreaterThan 300
New-ConditionalText -ConditionalType LessThan 300 -BackgroundColor cyan New-ConditionalText -ConditionalType LessThan 300 -BackgroundColor cyan
) )
$data | Export-Excel $file2 -Show -ConditionalText $( $data | Export-Excel $xlSourcefile2 -Show -ConditionalText $(
New-ConditionalText -ConditionalType GreaterThanOrEqual 275 New-ConditionalText -ConditionalType GreaterThanOrEqual 275
New-ConditionalText -ConditionalType LessThanOrEqual 250 -BackgroundColor cyan New-ConditionalText -ConditionalType LessThanOrEqual 250 -BackgroundColor cyan
) )

View File

@@ -1,4 +1,6 @@
$xlfile = "$env:TEMP\test.xlsx" try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:TEMP\test.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue Remove-Item $xlfile -ErrorAction SilentlyContinue
$data = ConvertFrom-csv @" $data = ConvertFrom-csv @"

View File

@@ -1,7 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$f = "$env:temp\dashboard.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $f -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = @" $data = @"
From,To,RDollars,RPercent,MDollars,MPercent,Revenue,Margin From,To,RDollars,RPercent,MDollars,MPercent,Revenue,Margin
@@ -13,9 +15,9 @@ New York,San Francisco,3221000,.0629,1088000,.04,436,21
New York,Phoneix,2782000,.0723,467000,.10,674,33 New York,Phoneix,2782000,.0723,467000,.10,674,33
"@ | ConvertFrom-Csv "@ | ConvertFrom-Csv
$data | Export-Excel $f -AutoSize $data | Export-Excel $xlSourcefile -AutoSize
$excel = Open-ExcelPackage $f $excel = Open-ExcelPackage $xlSourcefile
$sheet1 = $excel.Workbook.Worksheets["sheet1"] $sheet1 = $excel.Workbook.Worksheets["sheet1"]

View File

@@ -1,8 +1,11 @@
# DSUM # DSUM
# Adds the numbers in a field (column) of records in a list or database that match conditions that you specify. # Adds the numbers in a field (column) of records in a list or database that match conditions that you specify.
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:TEMP\test.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $xlfile -ErrorAction SilentlyContinue $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = ConvertFrom-Csv @" $data = ConvertFrom-Csv @"
Color,Date,Sales Color,Date,Sales
@@ -14,7 +17,7 @@ Red,1/17/2018,150
Blue,1/17/2018,300 Blue,1/17/2018,300
"@ "@
$xl = Export-Excel -InputObject $data -Path $xlfile -AutoSize -AutoFilter -TableName SalesInfo -AutoNameRange -PassThru $xl = Export-Excel -InputObject $data -Path $xlSourcefile -AutoSize -AutoFilter -TableName SalesInfo -AutoNameRange -PassThru
$databaseAddress = $xl.Sheet1.Dimension.Address $databaseAddress = $xl.Sheet1.Dimension.Address
Set-Format -Worksheet $xl.Sheet1 -Range C:C -NumberFormat '$##0' Set-Format -Worksheet $xl.Sheet1 -Range C:C -NumberFormat '$##0'

View File

@@ -1,5 +1,9 @@
$xlfile = "$env:TEMP\test.xlsx" try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item $xlfile -ErrorAction SilentlyContinue
#Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = ConvertFrom-Csv @" $data = ConvertFrom-Csv @"
Fruit,Amount Fruit,Amount
@@ -9,11 +13,11 @@ Bananas,60
Lemons,40 Lemons,40
"@ "@
$xl = Export-Excel -InputObject $data -Path $xlfile -PassThru -AutoSize $xl = Export-Excel -InputObject $data -Path $xlSourcefile -PassThru -AutoSize
Set-ExcelRange -Worksheet $xl.Sheet1 -Range D2 -BackgroundColor LightBlue -Value Apples Set-ExcelRange -Worksheet $xl.Sheet1 -Range D2 -BackgroundColor LightBlue -Value Apples
$Rows = $xl.Sheet1.Dimension.Rows $rows = $xl.Sheet1.Dimension.Rows
Set-ExcelRange -Worksheet $xl.Sheet1 -Range E2 -Formula "=VLookup(D2,A2:B$($Rows),2,FALSE)" Set-ExcelRange -Worksheet $xl.Sheet1 -Range E2 -Formula "=VLookup(D2,A2:B$($rows),2,FALSE)"
Close-ExcelPackage $xl -Show Close-ExcelPackage $xl -Show

View File

@@ -15,8 +15,10 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$path = "$Env:TEMP\DataValidation.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $path -ErrorAction SilentlyContinue $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$data = ConvertFrom-Csv -InputObject @" $data = ConvertFrom-Csv -InputObject @"
ID,Region,Product,Quantity,Price ID,Region,Product,Quantity,Price
@@ -29,7 +31,7 @@ ID,Region,Product,Quantity,Price
# Export the raw data # Export the raw data
$excelPackage = $Data | $excelPackage = $Data |
Export-Excel -WorksheetName "Sales" -Path $path -PassThru Export-Excel -WorksheetName "Sales" -Path $xlSourcefile -PassThru
# Creates a sheet with data that will be used in a validation rule # Creates a sheet with data that will be used in a validation rule
$excelPackage = @('Chisel', 'Crowbar', 'Drill', 'Hammer', 'Nails', 'Saw', 'Screwdriver', 'Wrench') | $excelPackage = @('Chisel', 'Crowbar', 'Drill', 'Hammer', 'Nails', 'Saw', 'Screwdriver', 'Wrench') |

View File

@@ -1,7 +1,9 @@
. "$PSScriptRoot\Export-MultipleExcelSheets.ps1" . "$PSScriptRoot\Export-MultipleExcelSheets.ps1"
$xlfile = "$env:TEMP\test.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $xlfile -ErrorAction SilentlyContinue $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$p = Get-Process $p = Get-Process
@@ -14,4 +16,4 @@ $InfoMap = @{
WillNotGetExported = "Hello World" WillNotGetExported = "Hello World"
} }
Export-MultipleExcelSheets -Path $xlfile -InfoMap $InfoMap -Show -AutoSize Export-MultipleExcelSheets -Path $xlSourcefile -InfoMap $InfoMap -Show -AutoSize

View File

@@ -2,8 +2,10 @@ param ($fibonacciDigits=10)
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$file = "fib.xlsx" #Get rid of pre-exisiting sheet
Remove-Item "fib.xlsx" -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$( $(
New-PSItem 0 New-PSItem 0
@@ -15,4 +17,4 @@ $(
New-PSItem ('=a{0}+a{1}' -f ($_+1),$_) New-PSItem ('=a{0}+a{1}' -f ($_+1),$_)
} }
) )
) | Export-Excel $file -Show ) | Export-Excel $xlSourcefile -Show

View File

@@ -1,10 +1,13 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:temp\testFmt.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
Get-Process | Get-Process |
Select-Object Company,Handles,PM, NPM| Select-Object Company,Handles,PM, NPM|
Export-Excel $xlfile -Show -AutoSize -CellStyleSB { Export-Excel $xlSourcefile -Show -AutoSize -CellStyleSB {
param( param(
$workSheet, $workSheet,
$totalRows, $totalRows,

View File

@@ -1,4 +1,6 @@
$data = ConvertFrom-Csv @' try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$data = ConvertFrom-Csv @'
Item,Quantity,Price,Total Cost Item,Quantity,Price,Total Cost
Footballs,9,21.95,197.55 Footballs,9,21.95,197.55
Cones,36,7.99,287.64 Cones,36,7.99,287.64

View File

@@ -1,7 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:temp\testFmt.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $xlfile -ErrorAction Ignore $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$RandomStyle = { $RandomStyle = {
param( param(
@@ -17,4 +19,4 @@ $RandomStyle = {
Get-Process | Get-Process |
Select-Object Company,Handles,PM, NPM| Select-Object Company,Handles,PM, NPM|
Export-Excel $xlfile -Show -AutoSize -CellStyleSB $RandomStyle Export-Excel $xlSourcefile -Show -AutoSize -CellStyleSB $RandomStyle

View File

@@ -1,10 +1,13 @@
$xlfile = "$env:TEMP\Points.xlsx" try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item $xlfile -ErrorAction SilentlyContinue #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$PivotTableDefinition = New-PivotTableDefinition -Activate -PivotTableName Points ` $PivotTableDefinition = New-PivotTableDefinition -Activate -PivotTableName Points `
-PivotRows Driver, Date -PivotData @{Points = "SUM"} -GroupDateRow Date -GroupDatePart Years, Months -PivotRows Driver, Date -PivotData @{Points = "SUM"} -GroupDateRow Date -GroupDatePart Years, Months
Import-Csv "$PSScriptRoot\First10Races.csv" | Import-Csv "$PSScriptRoot\First10Races.csv" |
Select-Object Race, @{n = "Date"; e = {[datetime]::ParseExact($_.date, "dd/MM/yyyy", (Get-Culture))}}, FinishPosition, Driver, GridPosition, Team, Points | Select-Object Race, @{n = "Date"; e = {[datetime]::ParseExact($_.date, "dd/MM/yyyy", (Get-Culture))}}, FinishPosition, Driver, GridPosition, Team, Points |
Export-Excel $xlfile -Show -AutoSize -PivotTableDefinition $PivotTableDefinition Export-Excel $xlSourcefile -Show -AutoSize -PivotTableDefinition $PivotTableDefinition

View File

@@ -1,10 +1,13 @@
$xlfile = "$env:TEMP\Places.xlsx" try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item $xlfile -ErrorAction SilentlyContinue #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$PivotTableDefinition = New-PivotTableDefinition -Activate -PivotTableName Places ` $PivotTableDefinition = New-PivotTableDefinition -Activate -PivotTableName Places `
-PivotRows Driver, FinishPosition -PivotData @{Date = "Count"} -GroupNumericRow FinishPosition -GroupNumericMin 1 -GroupNumericMax 25 -GroupNumericInterval 3 -PivotRows Driver, FinishPosition -PivotData @{Date = "Count"} -GroupNumericRow FinishPosition -GroupNumericMin 1 -GroupNumericMax 25 -GroupNumericInterval 3
Import-Csv "$PSScriptRoot\First10Races.csv" | Import-Csv "$PSScriptRoot\First10Races.csv" |
Select-Object Race, @{n = "Date"; e = {[datetime]::ParseExact($_.date, "dd/MM/yyyy", (Get-Culture))}}, FinishPosition, Driver, GridPosition, Team, Points | Select-Object Race, @{n = "Date"; e = {[datetime]::ParseExact($_.date, "dd/MM/yyyy", (Get-Culture))}}, FinishPosition, Driver, GridPosition, Team, Points |
Export-Excel $xlfile -Show -AutoSize -PivotTableDefinition $PivotTableDefinition Export-Excel $xlSourcefile -Show -AutoSize -PivotTableDefinition $PivotTableDefinition

View File

@@ -1,3 +1,4 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$data = ConvertFrom-Csv @" $data = ConvertFrom-Csv @"
Timestamp,Tenant Timestamp,Tenant
10/29/2018 3:00:00.123,1 10/29/2018 3:00:00.123,1
@@ -15,8 +16,10 @@ Timestamp,Tenant
10/29/2018 3:02:00.999,1 10/29/2018 3:02:00.999,1
"@ | Select-Object @{n = 'Timestamp'; e = {Get-date $_.timestamp}}, tenant, @{n = 'Bucket'; e = { - (Get-date $_.timestamp).Second % 30}} "@ | Select-Object @{n = 'Timestamp'; e = {Get-date $_.timestamp}}, tenant, @{n = 'Bucket'; e = { - (Get-date $_.timestamp).Second % 30}}
$f = "$env:temp\pivottest.xlsx" #Get rid of pre-exisiting sheet
Remove-Item $f -ErrorAction SilentlyContinue $xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$pivotDefParams = @{ $pivotDefParams = @{
PivotTableName = 'Timestamp Buckets' PivotTableName = 'Timestamp Buckets'
@@ -29,7 +32,7 @@ $pivotDefParams = @{
$excelParams = @{ $excelParams = @{
PivotTableDefinition = New-PivotTableDefinition @pivotDefParams PivotTableDefinition = New-PivotTableDefinition @pivotDefParams
Path = $f Path = $xlSourcefile
WorkSheetname = "Log Data" WorkSheetname = "Log Data"
AutoSize = $true AutoSize = $true
AutoFilter = $true AutoFilter = $true

View File

@@ -3,6 +3,7 @@
#We will create links to each race in the first 10 rows of the spreadSheet #We will create links to each race in the first 10 rows of the spreadSheet
#The next row will be column labels #The next row will be column labels
#After that will come a block for each race. #After that will come a block for each race.
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
#Read the data, and decide how much space to leave for the hyperlinks #Read the data, and decide how much space to leave for the hyperlinks
$scriptPath = Split-Path -Path $MyInvocation.MyCommand.path -Parent $scriptPath = Split-Path -Path $MyInvocation.MyCommand.path -Parent

View File

@@ -1,4 +1,6 @@
#Get rid of pre-exisiting sheet try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
#Get rid of pre-exisiting sheet
$path = "$Env:TEMP\test.xlsx" $path = "$Env:TEMP\test.xlsx"
remove-item -Path $path -ErrorAction SilentlyContinue remove-item -Path $path -ErrorAction SilentlyContinue

View File

@@ -1,3 +1,4 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$path = "$env:TEMP\Test.xlsx" $path = "$env:TEMP\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue Remove-item -Path $path -ErrorAction SilentlyContinue

View File

@@ -1,15 +1,16 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlfile = "$env:temp\AllSales.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $xlfile -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$params = @{ $params = @{
AutoSize = $true AutoSize = $true
AutoFilter = $true AutoFilter = $true
AutoNameRange = $true AutoNameRange = $true
ExcelChartDefinition = New-ExcelChartDefinition -XRange Item -YRange UnitSold -Title 'Units Sold' ExcelChartDefinition = New-ExcelChartDefinition -XRange Item -YRange UnitSold -Title 'Units Sold'
Path = $xlfile Path = $xlSourcefile
} }
#Import 4 sets of sales data from 4 CSV files, using the parameters above. #Import 4 sets of sales data from 4 CSV files, using the parameters above.
Import-Csv $PSScriptRoot\NorthSales.csv | Export-Excel -WorkSheetname North @params Import-Csv $PSScriptRoot\NorthSales.csv | Export-Excel -WorkSheetname North @params

View File

@@ -1,8 +1,9 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return} try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
$xlFile = "$env:TEMP\mw.xlsx" #Get rid of pre-exisiting sheet
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
Remove-Item $xlFile -ErrorAction Ignore Write-Verbose -Verbose -Message "Save location: $xlSourcefile"
Remove-Item $xlSourcefile -ErrorAction Ignore
$leftCsv = @" $leftCsv = @"
MyProp1,MyProp2,Length MyProp1,MyProp2,Length
@@ -16,4 +17,4 @@ a,b,10
c,d,21 c,d,21
"@ | ConvertFrom-Csv "@ | ConvertFrom-Csv
Merge-Worksheet -OutputFile $xlFile -ReferenceObject $leftCsv -DifferenceObject $rightCsv -Key Length -Show Merge-Worksheet -OutputFile $xlSourcefile -ReferenceObject $leftCsv -DifferenceObject $rightCsv -Key Length -Show

View File

@@ -1,3 +1,5 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue
#Get a subset of services into $s and export them #Get a subset of services into $s and export them

View File

@@ -1,3 +1,5 @@
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\Combined*.xlsx" -ErrorAction SilentlyContinue
#Get a subset of services into $s and export them #Get a subset of services into $s and export them

View File

@@ -7,7 +7,7 @@ param(
$InterestRate = .065, $InterestRate = .065,
$Term = 30 $Term = 30
) )
try {Import-Module $PSScriptRoot\..\..\ImportExcel.psd1} catch {throw ; return}
function New-CellData { function New-CellData {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification='Does not change system state')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification='Does not change system state')]
param( param(