Replace $env:TEMP

This commit is contained in:
ili101
2019-08-26 15:55:43 +03:00
parent 6650ecd5b8
commit d1592f8739
16 changed files with 73 additions and 86 deletions

View File

@@ -5,7 +5,7 @@
$measure = "Open"
)
$xl = "$env:TEMP\Stocks.xlsx"
$xl = Join-Path ([IO.Path]::GetTempPath()) 'Stocks.xlsx'
Remove-Item $xl -ErrorAction SilentlyContinue

View File

@@ -20,7 +20,7 @@ South,avocado,73
}
BeforeEach {
$xlfile = "$env:TEMP\trendLine.xlsx"
$xlfile = "TestDrive:\trendLine.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
}

View File

@@ -5,9 +5,9 @@ else {Add-Type -AssemblyName System.Window
Describe "Compare Worksheet" {
Context "Simple comparison output" {
BeforeAll {
Remove-Item -Path "$env:temp\server*.xlsx"
Remove-Item -Path "TestDrive:\server*.xlsx"
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property Name, RequiredServices, CanPauseAndContinue, CanShutdown, CanStop, DisplayName, DependentServices, MachineName
$s | Export-Excel -Path $env:temp\server1.xlsx
$s | Export-Excel -Path TestDrive:\server1.xlsx
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s
$row4Displayname = $s[2].DisplayName
$s[2].DisplayName = "Changed from the orginal"
@@ -17,9 +17,9 @@ Describe "Compare Worksheet" {
$s.Insert(3,$d)
$row6Name = $s[5].name
$s.RemoveAt(5)
$s | Export-Excel -Path $env:temp\server2.xlsx
$s | Export-Excel -Path TestDrive:\server2.xlsx
#Assume default worksheet name, (sheet1) and column header for key ("name")
$comp = compare-WorkSheet "$env:temp\server1.xlsx" "$env:temp\server2.xlsx" | Sort-Object -Property _row, _file
$comp = compare-WorkSheet "TestDrive:\Server1.xlsx" "TestDrive:\Server2.xlsx" | Sort-Object -Property _row, _file
}
it "Found the right number of differences " {
$comp | should not beNullOrEmpty
@@ -55,13 +55,13 @@ Describe "Compare Worksheet" {
$ModulePath = (Get-Command -Name 'Compare-WorkSheet').Module.Path
$PowerShellExec = if ($PSEdition -eq 'Core') {'pwsh.exe'} else {'powershell.exe'}
$PowerShellPath = Join-Path -Path $PSHOME -ChildPath $PowerShellExec
. $PowerShellPath -Command ("Import-Module $ModulePath; " + '$null = Compare-WorkSheet "$env:temp\server1.xlsx" "$env:temp\server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView; Start-Sleep -sec 5')
. $PowerShellPath -Command ("Import-Module $ModulePath; " + '$null = Compare-WorkSheet "TestDrive:\Server1.xlsx" "TestDrive:\Server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView; Start-Sleep -sec 5')
}
else {
$null = Compare-WorkSheet "$env:temp\server1.xlsx" "$env:temp\server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView:$useGrid
$null = Compare-WorkSheet "TestDrive:\Server1.xlsx" "TestDrive:\Server2.xlsx" -BackgroundColor ([System.Drawing.Color]::LightGreen) -GridView:$useGrid
}
$xl1 = Open-ExcelPackage -Path "$env:temp\server1.xlsx"
$xl2 = Open-ExcelPackage -Path "$env:temp\server2.xlsx"
$xl1 = Open-ExcelPackage -Path "TestDrive:\Server1.xlsx"
$xl2 = Open-ExcelPackage -Path "TestDrive:\Server2.xlsx"
$s1Sheet = $xl1.Workbook.Worksheets[1]
$s2Sheet = $xl2.Workbook.Worksheets[1]
}
@@ -85,9 +85,9 @@ Describe "Compare Worksheet" {
Context "Setting the forgound to highlight changed properties" {
BeforeAll {
$null = compare-WorkSheet "$env:temp\server1.xlsx" "$env:temp\server2.xlsx" -AllDataBackgroundColor([System.Drawing.Color]::white) -BackgroundColor ([System.Drawing.Color]::LightGreen) -FontColor ([System.Drawing.Color]::DarkRed)
$xl1 = Open-ExcelPackage -Path "$env:temp\server1.xlsx"
$xl2 = Open-ExcelPackage -Path "$env:temp\server2.xlsx"
$null = compare-WorkSheet "TestDrive:\Server1.xlsx" "TestDrive:\Server2.xlsx" -AllDataBackgroundColor([System.Drawing.Color]::white) -BackgroundColor ([System.Drawing.Color]::LightGreen) -FontColor ([System.Drawing.Color]::DarkRed)
$xl1 = Open-ExcelPackage -Path "TestDrive:\Server1.xlsx"
$xl2 = Open-ExcelPackage -Path "TestDrive:\Server2.xlsx"
$s1Sheet = $xl1.Workbook.Worksheets[1]
$s2Sheet = $xl2.Workbook.Worksheets[1]
}
@@ -116,7 +116,7 @@ Describe "Compare Worksheet" {
BeforeAll {
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property RequiredServices, CanPauseAndContinue, CanShutdown, CanStop,
DisplayName, DependentServices, MachineName, ServiceName, ServicesDependedOn, ServiceHandle, Status, ServiceType, StartType -ExcludeProperty Name
$s | Export-Excel -Path $env:temp\server1.xlsx -WorkSheetname Server1
$s | Export-Excel -Path TestDrive:\server1.xlsx -WorkSheetname Server1
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s
$row4Displayname = $s[2].DisplayName
$s[2].DisplayName = "Changed from the orginal"
@@ -128,11 +128,11 @@ Describe "Compare Worksheet" {
$s.RemoveAt(5)
$s[10].ServiceType = "Changed should not matter"
$s | Select-Object -Property ServiceName, DisplayName, StartType, ServiceType | Export-Excel -Path $env:temp\server2.xlsx -WorkSheetname server2
$s | Select-Object -Property ServiceName, DisplayName, StartType, ServiceType | Export-Excel -Path TestDrive:\server2.xlsx -WorkSheetname server2
#Assume default worksheet name, (sheet1) and column header for key ("name")
$comp = compare-WorkSheet "$env:temp\server1.xlsx" "$env:temp\server2.xlsx" -WorkSheetName Server1,Server2 -Key ServiceName -Property DisplayName,StartType -AllDataBackgroundColor ([System.Drawing.Color]::AliceBlue) -BackgroundColor ([System.Drawing.Color]::White) -FontColor ([System.Drawing.Color]::Red) | Sort-Object _row,_file
$xl1 = Open-ExcelPackage -Path "$env:temp\server1.xlsx"
$xl2 = Open-ExcelPackage -Path "$env:temp\server2.xlsx"
$comp = compare-WorkSheet "TestDrive:\Server1.xlsx" "TestDrive:\Server2.xlsx" -WorkSheetName Server1,Server2 -Key ServiceName -Property DisplayName,StartType -AllDataBackgroundColor ([System.Drawing.Color]::AliceBlue) -BackgroundColor ([System.Drawing.Color]::White) -FontColor ([System.Drawing.Color]::Red) | Sort-Object _row,_file
$xl1 = Open-ExcelPackage -Path "TestDrive:\Server1.xlsx"
$xl2 = Open-ExcelPackage -Path "TestDrive:\Server2.xlsx"
$s1Sheet = $xl1.Workbook.Worksheets["server1"]
$s2Sheet = $xl2.Workbook.Worksheets["server2"]
}
@@ -188,10 +188,10 @@ Describe "Compare Worksheet" {
Describe "Merge Worksheet" {
Context "Merge with 3 properties" {
BeforeAll {
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\combined*.xlsx" -ErrorAction SilentlyContinue
Remove-Item -Path "TestDrive:\server*.xlsx" , "TestDrive:\Combined*.xlsx" -ErrorAction SilentlyContinue
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property *
$s | Export-Excel -Path $env:temp\server1.xlsx
$s | Export-Excel -Path TestDrive:\server1.xlsx
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s
$s[2].DisplayName = "Changed from the orginal"
@@ -203,10 +203,10 @@ Describe "Merge Worksheet" {
$s.RemoveAt(5)
$s | Export-Excel -Path $env:temp\server2.xlsx
$s | Export-Excel -Path TestDrive:\server2.xlsx
#Assume default worksheet name, (sheet1) and column header for key ("name")
Merge-Worksheet -Referencefile "$env:temp\server1.xlsx" -Differencefile "$env:temp\server2.xlsx" -OutputFile "$env:temp\combined1.xlsx" -Property name,displayname,startType -Key name
$excel = Open-ExcelPackage -Path "$env:temp\combined1.xlsx"
Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\Server2.xlsx" -OutputFile "TestDrive:\combined1.xlsx" -Property name,displayname,startType -Key name
$excel = Open-ExcelPackage -Path "TestDrive:\combined1.xlsx"
$ws = $excel.Workbook.Worksheets["sheet1"]
}
it "Created a worksheet with the correct headings " {
@@ -247,16 +247,16 @@ Describe "Merge Worksheet" {
}
Context "Wider data set" {
it "Coped with columns beyond Z in the Output sheet " {
{ Merge-Worksheet -Referencefile "$env:temp\server1.xlsx" -Differencefile "$env:temp\server2.xlsx" -OutputFile "$env:temp\combined2.xlsx" } | Should not throw
{ Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\Server2.xlsx" -OutputFile "TestDrive:\combined2.xlsx" } | Should not throw
}
}
}
Describe "Merge Multiple sheets" {
Context "Merge 3 sheets with 3 properties" {
BeforeAll {
Remove-Item -Path "$env:temp\server*.xlsx" , "$env:temp\combined*.xlsx" -ErrorAction SilentlyContinue
Remove-Item -Path "TestDrive:\server*.xlsx" , "TestDrive:\Combined*.xlsx" -ErrorAction SilentlyContinue
[System.Collections.ArrayList]$s = get-service | Select-Object -first 25 -Property Name,DisplayName,StartType
$s | Export-Excel -Path $env:temp\server1.xlsx
$s | Export-Excel -Path TestDrive:\server1.xlsx
#$s is a zero based array, excel rows are 1 based and excel has a header row so Excel rows will be 2 + index in $s
$row4Displayname = $s[2].DisplayName
@@ -269,7 +269,7 @@ Describe "Merge Multiple sheets" {
$s.RemoveAt(5)
$s | Export-Excel -Path $env:temp\server2.xlsx
$s | Export-Excel -Path TestDrive:\server2.xlsx
$s[2].displayname = $row4Displayname
@@ -279,10 +279,10 @@ Describe "Merge Multiple sheets" {
$s.Insert(6,$d)
$s.RemoveAt(8)
$s | Export-Excel -Path $env:temp\server3.xlsx
$s | Export-Excel -Path TestDrive:\server3.xlsx
Merge-MultipleSheets -Path "$env:temp\server1.xlsx", "$env:temp\server2.xlsx","$env:temp\server3.xlsx" -OutputFile "$env:temp\combined3.xlsx" -Property name,displayname,startType -Key name
$excel = Open-ExcelPackage -Path "$env:temp\combined3.xlsx"
Merge-MultipleSheets -Path "TestDrive:\server1.xlsx", "TestDrive:\Server2.xlsx","TestDrive:\Server3.xlsx" -OutputFile "TestDrive:\combined3.xlsx" -Property name,displayname,startType -Key name
$excel = Open-ExcelPackage -Path "TestDrive:\combined3.xlsx"
$ws = $excel.Workbook.Worksheets["sheet1"]
}

View File

@@ -1,6 +1,6 @@
#Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force
$xlFile = "$env:TEMP\testSQL.xlsx"
$xlFile = "TestDrive:\testSQL.xlsx"
Describe "ConvertFrom-ExcelToSQLInsert" {

View File

@@ -1,8 +1,5 @@
if ($PSVersionTable.os -and $PSVersionTable.os -notMatch 'Windows' ) {return} #Currently this test outputs windows services so only run on Windows.
if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
$path1 = "$env:TEMP\Test1.xlsx"
$path2 = "$env:TEMP\Test2.xlsx"
$path1 = "TestDrive:\Test1.xlsx"
$path2 = "TestDrive:\Test2.xlsx"
Remove-item -Path $path1, $path2 -ErrorAction SilentlyContinue
$ProcRange = Get-Process | Export-Excel $path1 -DisplayPropertySet -WorkSheetname Processes -ReturnRange
@@ -91,8 +88,8 @@ Describe "Copy-Worksheet" {
Context "Copy worksheet should close all files" {
BeforeAll {
$xlfile = "$env:TEMP\reports.xlsx"
$xlfileArchive = "$env:TEMP\reportsArchive.xlsx"
$xlfile = "TestDrive:\reports.xlsx"
$xlfileArchive = "TestDrive:\reportsArchive.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
Remove-Item $xlfileArchive -ErrorAction SilentlyContinue
@@ -119,8 +116,8 @@ Describe "Copy-Worksheet" {
Context "Copy worksheet should support piped input" {
BeforeAll {
$xlfile = "$env:TEMP\reports.xlsx"
$xlfileArchive = "$env:TEMP\reportsArchive.xlsx"
$xlfile = "TestDrive:\reports.xlsx"
$xlfileArchive = "TestDrive:\reportsArchive.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
Remove-Item $xlfileArchive -ErrorAction SilentlyContinue

View File

@@ -8,7 +8,7 @@ if (Get-process -Name Excel,xlim -ErrorAction SilentlyContinue) { Write-Warni
Describe ExportExcel {
Context "#Example 1 # Creates and opens a file with the right number of rows and columns" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#Test with a maximum of 100 processes for speed; export all properties, then export smaller subsets.
$processes = Get-Process | where {$_.StartTime} | Select-Object -first 100 -Property * -excludeProperty Parent
@@ -70,7 +70,7 @@ Describe ExportExcel {
}
Context " # NoAliasOrScriptPropeties -ExcludeProperty and -DisplayPropertySet work" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
$processes = Get-Process | Select-Object -First 100
$propertyNames = $Processes[0].psobject.properties.where( {$_.MemberType -eq 'Property'}).name
@@ -119,7 +119,7 @@ Describe ExportExcel {
Context "#Example 2 # Exports a list of numbers and applies number format " {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#testing -ReturnRange switch and applying number format to Formulas as well as values.
$returnedRange = @($null, -1, 0, 34, 777, "", -0.5, 119, -0.1, 234, 788,"=A9+A10") | Export-Excel -NumberFormat '[Blue]$#,##0.00;[Red]-$#,##0.00' -Path $path -ReturnRange
@@ -158,7 +158,7 @@ Describe ExportExcel {
Context " # Number format parameter" {
BeforeAll {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
1..10 | Export-Excel -Path $path -Numberformat 'Number'
1..10 | Export-Excel -Path $path -Numberformat 'Percentage' -Append
@@ -181,7 +181,7 @@ Describe ExportExcel {
if ((Get-Culture).NumberFormat.CurrencySymbol -eq "£") {$OtherCurrencySymbol = "$"}
else {$OtherCurrencySymbol = "£"}
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
$warnVar = $null
#Test correct export of different data types and number formats; test hyperlinks, test -NoNumberConversion test object is converted to a string with no warnings, test calcuation of formula
Remove-item -Path $path -ErrorAction SilentlyContinue
@@ -298,7 +298,7 @@ Describe ExportExcel {
Context "# # Setting cells for different data types with -noHeader" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#Test -NoHeader & -NoNumberConversion
[PSCustOmobject][Ordered]@{
@@ -359,7 +359,7 @@ Describe ExportExcel {
#Test New-ConditionalText builds correctly
$ct = New-ConditionalText -ConditionalType GreaterThan 525 -ConditionalTextColor ([System.Drawing.Color]::DarkRed) -BackgroundColor ([System.Drawing.Color]::LightPink)
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#Test -ConditionalText with a single conditional spec.
Write-Output 489 668 299 777 860 151 119 497 234 788 | Export-Excel -Path $path -ConditionalText $ct
@@ -389,7 +389,7 @@ Describe ExportExcel {
Context "#Example 6 # Adding multiple conditional formats using short form syntax. " {
if ($notwindows) {Write-warning "Test only runs on Windows" ; return}
#Test adding mutliple conditional blocks and using the minimal syntax for new-ConditionalText
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#Testing -Passthrough
@@ -451,7 +451,7 @@ Describe ExportExcel {
}
Context "#Examples 8 & 9 # Adding Pivot tables and charts from parameters" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
#Test -passthru and -worksheetName creating a new, named, sheet in an existing file.
$Script:Procs= Get-Process | Select-Object -first 20 -Property Name, cpu, pm, handles, company
if ($Procs.count -lt 20) {Write-warning "Not enough proceses were returned by get-Process to run the test." ; return}
@@ -512,7 +512,7 @@ Describe ExportExcel {
}
Context " # Add-Worksheet inserted sheets, moved them correctly, and copied a sheet" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
#Test the -CopySource and -Movexxxx parameters for Add-WorkSheet
$Excel = Open-ExcelPackage $path
#At this point Sheets Should be in the order Sheet1, Processes, ProcessesPivotTable
@@ -547,7 +547,7 @@ Describe ExportExcel {
}
Context " # Create and append with Start row and Start Column, inc ranges and Pivot table. " {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
remove-item -Path $path -ErrorAction SilentlyContinue
#Catch warning
$warnVar = $null
@@ -599,7 +599,7 @@ Describe ExportExcel {
}
Context " # Create and append explicit and auto table and range extension" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
#Test -Append automatically extends a table, even when it is not specified in the append command;
$Script:Procs= Get-process
if ($Procs.count -lt 20) {Write-warning "Not enough proceses were returned by get-Process to run the test." ; return}
@@ -635,8 +635,7 @@ Describe ExportExcel {
}
Context "#Example 11 # Create and append with title, inc ranges and Pivot table" {
if ($Procs.count -lt 20) {Write-warning "Not enough proceses were returned by get-Process to run the test." ; return}
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
#Test New-PivotTableDefinition builds definition using -Pivotfilter and -PivotTotals options.
$ptDef = [ordered]@{}
$ptDef += New-PivotTableDefinition -PivotTableName "PT1" -SourceWorkSheet 'Sheet1' -PivotRows "Status" -PivotData @{'Status' = 'Count'} -PivotTotals Columns -PivotFilter "StartType" -IncludePivotChart -ChartType BarClustered3D -ChartTitle "Services by status" -ChartHeight 512 -ChartWidth 768 -ChartRow 10 -ChartColumn 0 -NoLegend -PivotColumns CanPauseAndContinue
@@ -718,8 +717,8 @@ Describe ExportExcel {
}
Context "#Example 13 # Formatting and another way to do a pivot. " {
$path = Join-Path $Env:TEMP "test.xlsx"
Remove-Item $path -ErrorAction SilentlyContinue
$path = "TestDrive:\Test.xlsx"
Remove-Item $path
#Test freezing top row/first column, adding formats and a pivot table - from Add-Pivot table not a specification variable - after the export
$excel = Get-Process | Select-Object -Property Name, Company, Handles, CPU, PM, NPM, WS | Export-Excel -Path $path -ClearSheet -WorkSheetname "Processes" -FreezeTopRowFirstColumn -PassThru
$sheet = $excel.Workbook.Worksheets["Processes"]
@@ -800,7 +799,7 @@ Describe ExportExcel {
}
Context " # Chart from MultiSeries.ps1 in the Examples\charts Directory" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
#Test we haven't missed any parameters on New-ChartDefinition which are on add chart or vice versa.
@@ -858,7 +857,7 @@ Describe ExportExcel {
}
Context " # variation of plot.ps1 from Examples Directory using Add chart outside ExportExcel" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
#Test inserting a fomual
$excel = 0..360 | ForEach-Object {[pscustomobject][ordered]@{x = $_; Sinx = "=Sin(Radians(x)) "}} | Export-Excel -AutoNameRange -Path $path -WorkSheetname SinX -ClearSheet -FreezeFirstColumn -PassThru
#Test-Add Excel Chart to existing data. Test add Conditional formatting with a formula
@@ -900,7 +899,7 @@ Describe ExportExcel {
}
Context " # Quick line chart" {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
#test drawing a chart when data doesn't have a string
0..360 | ForEach-Object {[pscustomobject][ordered]@{x = $_; Sinx = "=Sin(Radians(x)) "}} | Export-Excel -AutoNameRange -Path $path -LineChart
@@ -918,7 +917,7 @@ Describe ExportExcel {
}
Context " # Quick Pie chart and three icon conditional formating" {
$path = Join-Path $Env:TEMP "Pie.xlsx"
$path = "TestDrive:\Pie.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
$Script:Procs= Get-Process
if ($Procs.count -lt 20) {Write-warning "Not enough proceses were returned by get-Process to run the test." ; return}
@@ -957,8 +956,7 @@ Describe ExportExcel {
}
Context " # Awkward multiple tables" {
if ($notWindows) {Write-warning "Test only runs on Windows" ; return}
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
#Test creating 3 on overlapping tables on the same page. Create rightmost the left most then middle.
remove-item -Path $path -ErrorAction SilentlyContinue
$r = Get-ChildItem -path C:\WINDOWS\system32 -File
@@ -993,7 +991,7 @@ Describe ExportExcel {
}
Context " # Parameters and ParameterSets" {
$Path = join-path $env:TEMP "temp.xlsx"
$Path = "TestDrive:\test.xlsx"
Remove-Item -Path $Path -ErrorAction SilentlyContinue
$Processes = Get-Process | Select-Object -first 10 -Property Name, cpu, pm, handles, company

View File

@@ -1,7 +1,7 @@
if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
remove-item -path $path -ErrorAction SilentlyContinue
ConvertFrom-Csv @"
Product, City, Gross, Net

View File

@@ -5,7 +5,7 @@ $dataPath = Join-Path -Path $scriptPath -ChildPath "First10Races.csv"
Describe "Creating small named ranges with hyperlinks" {
BeforeAll {
$path = Join-Path $Env:TEMP "results.xlsx"
$path = "TestDrive:\Results.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
#Read race results, and group by race name : export 1 row to get headers, leaving enough rows aboce to put in a link for each race
$results = Import-Csv -Path $dataPath |

View File

@@ -2,7 +2,7 @@ if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
Describe "Exporting with -Inputobject" {
BeforeAll {
$path = Join-Path $Env:TEMP "results.xlsx"
$path = "TestDrive:\Results.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
#Read race results, and group by race name : export 1 row to get headers, leaving enough rows aboce to put in a link for each race
$results = ((Get-Process) + (Get-Process -id $PID)) | Select-Object -last 10 -Property Name, cpu, pm, handles, StartTime

View File

@@ -27,7 +27,7 @@ ID,Product,Quantity,Price,Total
Describe "Join Worksheet part 1" {
BeforeAll {
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
Remove-Item -Path $path -ErrorAction SilentlyContinue
$data1 | Export-Excel -Path $path -WorkSheetname Oxford
$data2 | Export-Excel -Path $path -WorkSheetname Abingdon
@@ -92,7 +92,7 @@ Describe "Join Worksheet part 1" {
}
}
}
$path = Join-Path $Env:TEMP "Test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-item -Path $path -ErrorAction SilentlyContinue
#switched to CIM objects so test runs on V6
Describe "Join Worksheet part 2" {

View File

@@ -8,7 +8,7 @@ Describe "Password Support" {
Context "Password protected sheet" {
BeforeAll {
$password = "YouMustRememberThis"
$path = "$env:TEMP\Test.xlsx"
$path = "TestDrive:\Test.xlsx"
Remove-Item $path -ErrorAction SilentlyContinue
Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet
}

View File

@@ -1,6 +1,4 @@
if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
Remove-Item -path $path -ErrorAction SilentlyContinue
$excel = ConvertFrom-Csv @"
Product, City, Gross, Net

View File

@@ -1,8 +1,4 @@
if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
$notWindows = ($PSVersionTable.os -and $PSVersionTable.os -notMatch 'Windows' )
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
describe "Consistent passing of ranges." {
if ($notWindows) {Write-warning -message "Test uses get-service so only works on Windows" ; return}
Context "Conditional Formatting" {

View File

@@ -10,7 +10,7 @@ Name,Age
Jane,10
John,20
"@
$xlFile1 = Join-Path $Env:TEMP "removeWorsheet1.xlsx"
$xlFile1 = "TestDrive:\RemoveWorsheet1.xlsx"
Remove-Item $xlFile1 -ErrorAction SilentlyContinue
$data | Export-Excel -Path $xlFile1 -WorksheetName Target1
@@ -18,7 +18,7 @@ John,20
$data | Export-Excel -Path $xlFile1 -WorksheetName Target3
$data | Export-Excel -Path $xlFile1 -WorksheetName Sheet1
$xlFile2 = Join-Path $Env:TEMP "removeWorsheet2.xlsx"
$xlFile2 = "TestDrive:\RemoveWorsheet2.xlsx"
Remove-Item $xlFile2 -ErrorAction SilentlyContinue
$data | Export-Excel -Path $xlFile2 -WorksheetName Target1
@@ -65,7 +65,7 @@ John,20
it "Should delete sheet from multiple workbooks".PadRight(87) {
Get-ChildItem (Join-Path $Env:TEMP "removeWorsheet*.xlsx") | Remove-WorkSheet
Get-ChildItem "TestDrive:\RemoveWorsheet*.xlsx" | Remove-WorkSheet
$actual = Get-ExcelSheetInfo -Path $xlFile1

View File

@@ -1,6 +1,4 @@
Import-Module $PSScriptRoot\..\ImportExcel.psd1 -Force
if (-not $env:TEMP) {$env:TEMP = [IO.Path]::GetTempPath() -replace "/$","" }
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
$data = ConvertFrom-Csv -InputObject @"
ID,Product,Quantity,Price
@@ -300,7 +298,7 @@ Describe "Conditional Formatting" {
}
}
$path = Join-Path $Env:TEMP "test.xlsx"
$path = "TestDrive:\test.xlsx"
$data2 = ConvertFrom-Csv -InputObject @"
ID,Product,Quantity,Price,Total
12001,Nails,37,3.99,147.63
@@ -321,7 +319,7 @@ ID,Product,Quantity,Price,Total
Describe "AutoNameRange data with a single property name" {
BeforeEach {
$xlfile = Join-Path $Env:TEMP "testNamedRange.xlsx"
$xlfile = "TestDrive:\testNamedRange.xlsx"
Remove-Item $xlfile -ErrorAction SilentlyContinue
}

View File

@@ -11,7 +11,7 @@ ID,Product,Quantity,Price
12011,Crowbar,7,23.48
"@
$path = Join-Path $Env:TEMP "DataValidation.xlsx"
$path = "TestDrive:\DataValidation.xlsx"
Describe "Data validation and protection" {
Context "Data Validation rules" {