mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Update Pester Syntax from V3 to V4 (V5 won't support the old version)
This commit is contained in:
@@ -29,7 +29,7 @@ function ConvertTo-PesterTest {
|
||||
|
||||
`$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)}
|
||||
|
||||
Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)'
|
||||
Invoke-RestMethod @p | Should -Be '$($record.ExpectedResult)'
|
||||
}
|
||||
|
||||
"@
|
||||
|
||||
@@ -30,7 +30,7 @@ function Test-APIReadXls {
|
||||
|
||||
`$target.psobject.Properties.name | ForEach-Object {`$p=@{}} {`$p.`$_=`$(`$target.`$_)}
|
||||
|
||||
Invoke-RestMethod @p | Should Be '$($record.ExpectedResult)'
|
||||
Invoke-RestMethod @p | Should -Be '$($record.ExpectedResult)'
|
||||
}
|
||||
|
||||
"@
|
||||
|
||||
@@ -32,7 +32,7 @@ South,avocado,73
|
||||
$excel = Open-ExcelPackage -Path $xlfile
|
||||
$ws = $excel.Workbook.Worksheets["Sheet1"]
|
||||
|
||||
$ws.Drawings[0].Series.TrendLines.Type | Should Be 'Linear'
|
||||
$ws.Drawings[0].Series.TrendLines.Type | Should -Be 'Linear'
|
||||
|
||||
Close-ExcelPackage $excel
|
||||
}
|
||||
@@ -45,7 +45,7 @@ South,avocado,73
|
||||
$excel = Open-ExcelPackage -Path $xlfile
|
||||
$ws = $excel.Workbook.Worksheets["Sheet1"]
|
||||
|
||||
$ws.Drawings[0].Series.TrendLines.Type | Should Be 'MovingAvgerage'
|
||||
$ws.Drawings[0].Series.TrendLines.Type | Should -Be 'MovingAvgerage'
|
||||
|
||||
Close-ExcelPackage $excel
|
||||
}
|
||||
|
||||
@@ -31,29 +31,29 @@ Describe "Compare Worksheet" {
|
||||
}
|
||||
Context "Simple comparison output" {
|
||||
it "Found the right number of differences " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp.Count | should be 4
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp.Count | Should -Be 4
|
||||
}
|
||||
it "Found the data row with a changed property " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[0]._Side | should not be $comp[1]._Side
|
||||
$comp[0]._Row | should be 4
|
||||
$comp[1]._Row | should be 4
|
||||
$comp[1].Name | should be $comp[0].Name
|
||||
$comp[0].DisplayName | should be $row4Displayname
|
||||
$comp[1].DisplayName | should be "Changed from the orginal"
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[0]._Side | Should -Not -Be $comp[1]._Side
|
||||
$comp[0]._Row | Should -Be 4
|
||||
$comp[1]._Row | Should -Be 4
|
||||
$comp[1].Name | Should -Be $comp[0].Name
|
||||
$comp[0].DisplayName | Should -Be $row4Displayname
|
||||
$comp[1].DisplayName | Should -Be "Changed from the orginal"
|
||||
}
|
||||
it "Found the inserted data row " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[2]._Side | should be '=>'
|
||||
$comp[2]._Row | should be 5
|
||||
$comp[2].Name | should be "Dummy"
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[2]._Side | Should -Be '=>'
|
||||
$comp[2]._Row | Should -Be 5
|
||||
$comp[2].Name | Should -Be "Dummy"
|
||||
}
|
||||
it "Found the deleted data row " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[3]._Side | should be '<='
|
||||
$comp[3]._Row | should be 6
|
||||
$comp[3].Name | should be $row6Name
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[3]._Side | Should -Be '<='
|
||||
$comp[3]._Row | Should -Be 6
|
||||
$comp[3].Name | Should -Be $row6Name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,16 +75,16 @@ Describe "Compare Worksheet" {
|
||||
$s2Sheet = $xl2.Workbook.Worksheets[1]
|
||||
}
|
||||
it "Set the background on the right rows " {
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
}
|
||||
it "Didn't set other cells " {
|
||||
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | should not be "FF90EE90"
|
||||
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | should not be "FF90EE90"
|
||||
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FF90EE90"
|
||||
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FF90EE90"
|
||||
}
|
||||
AfterAll {
|
||||
Close-ExcelPackage -ExcelPackage $xl1 -NoSave
|
||||
@@ -101,18 +101,18 @@ Describe "Compare Worksheet" {
|
||||
$s2Sheet = $xl2.Workbook.Worksheets[1]
|
||||
}
|
||||
it "Added foreground colour to the right cells " {
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | should be "FF90EE90"
|
||||
# $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | should be "FF8B0000"
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | should be "FF8B0000"
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FF90EE90"
|
||||
# $s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -Be "FF8B0000"
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -Be "FF8B0000"
|
||||
}
|
||||
it "Didn't set the foreground on other cells " {
|
||||
$s1Sheet.Cells["F5"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s2Sheet.Cells["F5"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s1Sheet.Cells["G4"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s2Sheet.Cells["G4"].Style.Font.Color.Rgb | should beNullOrEmpty
|
||||
$s1Sheet.Cells["F5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["F5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s1Sheet.Cells["G4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["G4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
|
||||
}
|
||||
AfterAll {
|
||||
@@ -146,46 +146,46 @@ Describe "Compare Worksheet" {
|
||||
$s2Sheet = $xl2.Workbook.Worksheets["server2"]
|
||||
}
|
||||
it "Found the right number of differences " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp.Count | should be 4
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp.Count | Should -Be 4
|
||||
}
|
||||
it "Found the data row with a changed property " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[0]._Side | should not be $comp[1]._Side
|
||||
$comp[0]._Row | should be 4
|
||||
$comp[1]._Row | should be 4
|
||||
$comp[1].ServiceName | should be $comp[0].ServiceName
|
||||
$comp[0].DisplayName | should be $row4Displayname
|
||||
$comp[1].DisplayName | should be "Changed from the orginal"
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[0]._Side | Should -Not -Be $comp[1]._Side
|
||||
$comp[0]._Row | Should -Be 4
|
||||
$comp[1]._Row | Should -Be 4
|
||||
$comp[1].ServiceName | Should -Be $comp[0].ServiceName
|
||||
$comp[0].DisplayName | Should -Be $row4Displayname
|
||||
$comp[1].DisplayName | Should -Be "Changed from the orginal"
|
||||
}
|
||||
it "Found the inserted data row " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[2]._Side | should be '=>'
|
||||
$comp[2]._Row | should be 5
|
||||
$comp[2].ServiceName | should be "Dummy"
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[2]._Side | Should -Be '=>'
|
||||
$comp[2]._Row | Should -Be 5
|
||||
$comp[2].ServiceName | Should -Be "Dummy"
|
||||
}
|
||||
it "Found the deleted data row " {
|
||||
$comp | should not beNullOrEmpty
|
||||
$comp[3]._Side | should be '<='
|
||||
$comp[3]._Row | should be 6
|
||||
$comp[3].ServiceName | should be $row6Name
|
||||
$comp | Should -Not -BeNullOrEmpty
|
||||
$comp[3]._Side | Should -Be '<='
|
||||
$comp[3]._Row | Should -Be 6
|
||||
$comp[3].ServiceName | Should -Be $row6Name
|
||||
}
|
||||
it "Set the background on the right rows " {
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | should be "FFFFFFFF"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should be "FFFFFFFF"
|
||||
$s1Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
|
||||
$s1Sheet.Cells["6:6"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
|
||||
$s2Sheet.Cells["4:4"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
|
||||
$s2Sheet.Cells["5:5"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFFFFFFF"
|
||||
|
||||
$s1Sheet.Cells["E4"].Style.Font.Color.Rgb | Should be "FFFF0000"
|
||||
$s2Sheet.Cells["E4"].Style.Font.Color.Rgb | Should be "FFFF0000"
|
||||
$s1Sheet.Cells["E4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
|
||||
$s2Sheet.Cells["E4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
|
||||
}
|
||||
it "Didn't set other cells " {
|
||||
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should not be "FFFFFFFF"
|
||||
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should not be "FFFFFFFF"
|
||||
$s1Sheet.Cells["E5"].Style.Font.Color.Rgb | Should beNullOrEmpty
|
||||
$s2Sheet.Cells["E5"].Style.Font.Color.Rgb | Should beNullOrEmpty
|
||||
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should beNullOrEmpty
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should beNullOrEmpty
|
||||
$s1Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FFFFFFFF"
|
||||
$s2Sheet.Cells["3:3"].Style.Fill.BackgroundColor.Rgb | Should -Not -Be "FFFFFFFF"
|
||||
$s1Sheet.Cells["E5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["E5"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s1Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
$s2Sheet.Cells["F4"].Style.Font.Color.Rgb | Should -BeNullOrEmpty
|
||||
}
|
||||
AfterAll {
|
||||
Close-ExcelPackage -ExcelPackage $xl1 -NoSave # -Show
|
||||
@@ -219,44 +219,44 @@ Describe "Merge Worksheet" {
|
||||
}
|
||||
Context "Merge with 3 properties" {
|
||||
it "Created a worksheet with the correct headings " {
|
||||
$ws | should not beNullOrEmpty
|
||||
$ws.Cells[ 1,1].Value | Should be "name"
|
||||
$ws.Cells[ 1,2].Value | Should be "DisplayName"
|
||||
$ws.Cells[ 1,3].Value | Should be "StartType"
|
||||
$ws.Cells[ 1,4].Value | Should be "server2 DisplayName"
|
||||
$ws.Cells[ 1,5].Value | Should be "server2 StartType"
|
||||
$ws | Should -Not -BeNullOrEmpty
|
||||
$ws.Cells[ 1,1].Value | Should -Be "name"
|
||||
$ws.Cells[ 1,2].Value | Should -Be "DisplayName"
|
||||
$ws.Cells[ 1,3].Value | Should -Be "StartType"
|
||||
$ws.Cells[ 1,4].Value | Should -Be "server2 DisplayName"
|
||||
$ws.Cells[ 1,5].Value | Should -Be "server2 StartType"
|
||||
}
|
||||
it "Joined the two sheets correctly " {
|
||||
$ws.Cells[ 2,2].Value | Should be $ws.Cells[ 2,4].Value
|
||||
$ws.Cells[ 2,3].Value | Should be $ws.Cells[ 2,5].Value
|
||||
$ws.cells[ 4,4].value | Should be "Changed from the orginal"
|
||||
$ws.cells[ 5,1].value | Should be "Dummy"
|
||||
$ws.cells[ 5,2].value | Should beNullOrEmpty
|
||||
$ws.cells[ 5,3].value | Should beNullOrEmpty
|
||||
$ws.cells[ 5,4].value | Should be "Dummy Service"
|
||||
$ws.cells[ 7,4].value | Should beNullOrEmpty
|
||||
$ws.cells[ 7,5].value | Should beNullOrEmpty
|
||||
$ws.Cells[12,2].Value | Should be $ws.Cells[12,4].Value
|
||||
$ws.Cells[12,3].Value | Should be $ws.Cells[12,5].Value
|
||||
$ws.Cells[ 2,2].Value | Should -Be $ws.Cells[ 2,4].Value
|
||||
$ws.Cells[ 2,3].Value | Should -Be $ws.Cells[ 2,5].Value
|
||||
$ws.cells[ 4,4].value | Should -Be "Changed from the orginal"
|
||||
$ws.cells[ 5,1].value | Should -Be "Dummy"
|
||||
$ws.cells[ 5,2].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 5,3].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 5,4].value | Should -Be "Dummy Service"
|
||||
$ws.cells[ 7,4].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 7,5].value | Should -BeNullOrEmpty
|
||||
$ws.Cells[12,2].Value | Should -Be $ws.Cells[12,4].Value
|
||||
$ws.Cells[12,3].Value | Should -Be $ws.Cells[12,5].Value
|
||||
}
|
||||
it "Highlighted the keys in the added / deleted / changed rows " {
|
||||
$ws.cells[4,1].Style.font.color.rgb | Should be "FF8b0000"
|
||||
$ws.cells[5,1].Style.font.color.rgb | Should be "FF8b0000"
|
||||
$ws.cells[7,1].Style.font.color.rgb | Should be "FF8b0000"
|
||||
$ws.cells[4,1].Style.font.color.rgb | Should -Be "FF8b0000"
|
||||
$ws.cells[5,1].Style.font.color.rgb | Should -Be "FF8b0000"
|
||||
$ws.cells[7,1].Style.font.color.rgb | Should -Be "FF8b0000"
|
||||
}
|
||||
it "Set the background for the added / deleted / changed rows " {
|
||||
$ws.cells["A3:E3"].style.Fill.BackgroundColor.Rgb | Should beNullOrEmpty
|
||||
$ws.cells["A4:E4"].style.Fill.BackgroundColor.Rgb | Should be "FFFFA500"
|
||||
$ws.cells["A5" ].style.Fill.BackgroundColor.Rgb | Should be "FF98FB98"
|
||||
$ws.cells["B5:C5"].style.Fill.BackgroundColor.rgb | Should beNullOrEmpty
|
||||
$ws.cells["D5:E5"].style.Fill.BackgroundColor.Rgb | Should be "FF98FB98"
|
||||
$ws.cells["A7:C7"].style.Fill.BackgroundColor.Rgb | Should be "FFFFB6C1"
|
||||
$ws.cells["D7:E7"].style.Fill.BackgroundColor.rgb | Should beNullOrEmpty
|
||||
$ws.cells["A3:E3"].style.Fill.BackgroundColor.Rgb | Should -BeNullOrEmpty
|
||||
$ws.cells["A4:E4"].style.Fill.BackgroundColor.Rgb | Should -Be "FFFFA500"
|
||||
$ws.cells["A5" ].style.Fill.BackgroundColor.Rgb | Should -Be "FF98FB98"
|
||||
$ws.cells["B5:C5"].style.Fill.BackgroundColor.rgb | Should -BeNullOrEmpty
|
||||
$ws.cells["D5:E5"].style.Fill.BackgroundColor.Rgb | Should -Be "FF98FB98"
|
||||
$ws.cells["A7:C7"].style.Fill.BackgroundColor.Rgb | Should -Be "FFFFB6C1"
|
||||
$ws.cells["D7:E7"].style.Fill.BackgroundColor.rgb | Should -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
Context "Wider data set" {
|
||||
it "Coped with columns beyond Z in the Output sheet " {
|
||||
{ Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\server2.xlsx" -OutputFile "TestDrive:\combined2.xlsx" } | Should not throw
|
||||
{ Merge-Worksheet -Referencefile "TestDrive:\server1.xlsx" -Differencefile "TestDrive:\server2.xlsx" -OutputFile "TestDrive:\combined2.xlsx" } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -296,64 +296,64 @@ Describe "Merge Multiple sheets" {
|
||||
|
||||
}
|
||||
it "Created a worksheet with the correct headings " {
|
||||
$ws | Should not beNullOrEmpty
|
||||
$ws.Cells[ 1,2 ].Value | Should be "name"
|
||||
$ws.Cells[ 1,3 ].Value | Should be "server1 DisplayName"
|
||||
$ws.Cells[ 1,4 ].Value | Should be "server1 StartType"
|
||||
$ws.Cells[ 1,5 ].Value | Should be "server2 DisplayName"
|
||||
$ws.Cells[ 1,6 ].Value | Should be "server2 StartType"
|
||||
$ws.Column(7).hidden | Should be $true
|
||||
$ws.Cells[ 1,8].Value | Should be "server2 Row"
|
||||
$ws.Cells[ 1,9 ].Value | Should be "server3 DisplayName"
|
||||
$ws.Cells[ 1,10].Value | Should be "server3 StartType"
|
||||
$ws.Column(11).hidden | Should be $true
|
||||
$ws.Cells[ 1,12].Value | Should be "server3 Row"
|
||||
$ws | Should -Not -BeNullOrEmpty
|
||||
$ws.Cells[ 1,2 ].Value | Should -Be "name"
|
||||
$ws.Cells[ 1,3 ].Value | Should -Be "server1 DisplayName"
|
||||
$ws.Cells[ 1,4 ].Value | Should -Be "server1 StartType"
|
||||
$ws.Cells[ 1,5 ].Value | Should -Be "server2 DisplayName"
|
||||
$ws.Cells[ 1,6 ].Value | Should -Be "server2 StartType"
|
||||
$ws.Column(7).hidden | Should -Be $true
|
||||
$ws.Cells[ 1,8].Value | Should -Be "server2 Row"
|
||||
$ws.Cells[ 1,9 ].Value | Should -Be "server3 DisplayName"
|
||||
$ws.Cells[ 1,10].Value | Should -Be "server3 StartType"
|
||||
$ws.Column(11).hidden | Should -Be $true
|
||||
$ws.Cells[ 1,12].Value | Should -Be "server3 Row"
|
||||
}
|
||||
it "Joined the three sheets correctly " {
|
||||
$ws.Cells[ 2,3 ].Value | Should be $ws.Cells[ 2,5 ].Value
|
||||
$ws.Cells[ 2,4 ].Value | Should be $ws.Cells[ 2,6 ].Value
|
||||
$ws.Cells[ 2,5 ].Value | Should be $ws.Cells[ 2,9 ].Value
|
||||
$ws.Cells[ 2,6 ].Value | Should be $ws.Cells[ 2,10].Value
|
||||
$ws.cells[ 4,5 ].value | Should be "Changed from the orginal"
|
||||
$ws.cells[ 4,9 ].value | Should be $ws.Cells[ 4,3 ].Value
|
||||
$ws.cells[ 5,2 ].value | Should be "Dummy"
|
||||
$ws.cells[ 5,3 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 5,4 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 5,5 ].value | Should be "Dummy Service"
|
||||
$ws.cells[ 5,8 ].value | Should be ($ws.cells[ 4,1].value +1)
|
||||
$ws.cells[ 5,9 ].value | Should be $ws.cells[ 5,5 ].value
|
||||
$ws.cells[ 7,5 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 7,6 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 7,9 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 7,10].value | Should beNullOrEmpty
|
||||
$ws.cells[ 8,3 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 8,4 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 8,5 ].value | Should beNullOrEmpty
|
||||
$ws.cells[ 8,6 ].value | Should beNullOrEmpty
|
||||
$ws.cells[11,9 ].value | Should beNullOrEmpty
|
||||
$ws.cells[11,10].value | Should beNullOrEmpty
|
||||
$ws.Cells[12,3 ].Value | Should be $ws.Cells[12,5].Value
|
||||
$ws.Cells[12,4 ].Value | Should be $ws.Cells[12,6].Value
|
||||
$ws.Cells[12,9 ].Value | Should be $ws.Cells[12,5].Value
|
||||
$ws.Cells[12,10].Value | Should be $ws.Cells[12,6].Value
|
||||
$ws.Cells[ 2,3 ].Value | Should -Be $ws.Cells[ 2,5 ].Value
|
||||
$ws.Cells[ 2,4 ].Value | Should -Be $ws.Cells[ 2,6 ].Value
|
||||
$ws.Cells[ 2,5 ].Value | Should -Be $ws.Cells[ 2,9 ].Value
|
||||
$ws.Cells[ 2,6 ].Value | Should -Be $ws.Cells[ 2,10].Value
|
||||
$ws.cells[ 4,5 ].value | Should -Be "Changed from the orginal"
|
||||
$ws.cells[ 4,9 ].value | Should -Be $ws.Cells[ 4,3 ].Value
|
||||
$ws.cells[ 5,2 ].value | Should -Be "Dummy"
|
||||
$ws.cells[ 5,3 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 5,4 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 5,5 ].value | Should -Be "Dummy Service"
|
||||
$ws.cells[ 5,8 ].value | Should -Be ($ws.cells[ 4,1].value +1)
|
||||
$ws.cells[ 5,9 ].value | Should -Be $ws.cells[ 5,5 ].value
|
||||
$ws.cells[ 7,5 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 7,6 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 7,9 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 7,10].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 8,3 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 8,4 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 8,5 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[ 8,6 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[11,9 ].value | Should -BeNullOrEmpty
|
||||
$ws.cells[11,10].value | Should -BeNullOrEmpty
|
||||
$ws.Cells[12,3 ].Value | Should -Be $ws.Cells[12,5].Value
|
||||
$ws.Cells[12,4 ].Value | Should -Be $ws.Cells[12,6].Value
|
||||
$ws.Cells[12,9 ].Value | Should -Be $ws.Cells[12,5].Value
|
||||
$ws.Cells[12,10].Value | Should -Be $ws.Cells[12,6].Value
|
||||
}
|
||||
it "Created Conditional formatting rules " {
|
||||
$cf=$ws.ConditionalFormatting
|
||||
$cf.Count | Should be 17
|
||||
$cf[16].Address.Address | Should be 'B2:B1048576'
|
||||
$cf[16].Type | Should be 'Expression'
|
||||
$cf[16].Formula | Should be 'OR(G2<>"Same",K2<>"Same")'
|
||||
$cf[16].Style.Font.Color.Color.Name | Should be "FFFF0000"
|
||||
$cf[14].Address.Address | Should be 'D2:D1048576'
|
||||
$cf[14].Type | Should be 'Expression'
|
||||
$cf[14].Formula | Should be 'OR(G2="Added",K2="Added")'
|
||||
$cf[14].Style.Fill.BackgroundColor.Color.Name | Should be 'ffffb6c1'
|
||||
$cf[14].Style.Fill.PatternType.ToString() | Should be 'Solid'
|
||||
$cf[ 0].Address.Address | Should be 'F1:F1048576'
|
||||
$cf[ 0].Type | Should be 'Expression'
|
||||
$cf[ 0].Formula | Should be 'G1="Added"'
|
||||
$cf[ 0].Style.Fill.BackgroundColor.Color.Name | Should be 'ffffa500'
|
||||
$cf[ 0].Style.Fill.PatternType.ToString() | Should be 'Solid'
|
||||
$cf.Count | Should -Be 17
|
||||
$cf[16].Address.Address | Should -Be 'B2:B1048576'
|
||||
$cf[16].Type | Should -Be 'Expression'
|
||||
$cf[16].Formula | Should -Be 'OR(G2<>"Same",K2<>"Same")'
|
||||
$cf[16].Style.Font.Color.Color.Name | Should -Be "FFFF0000"
|
||||
$cf[14].Address.Address | Should -Be 'D2:D1048576'
|
||||
$cf[14].Type | Should -Be 'Expression'
|
||||
$cf[14].Formula | Should -Be 'OR(G2="Added",K2="Added")'
|
||||
$cf[14].Style.Fill.BackgroundColor.Color.Name | Should -Be 'ffffb6c1'
|
||||
$cf[14].Style.Fill.PatternType.ToString() | Should -Be 'Solid'
|
||||
$cf[ 0].Address.Address | Should -Be 'F1:F1048576'
|
||||
$cf[ 0].Type | Should -Be 'Expression'
|
||||
$cf[ 0].Formula | Should -Be 'G1="Added"'
|
||||
$cf[ 0].Style.Fill.BackgroundColor.Color.Name | Should -Be 'ffffa500'
|
||||
$cf[ 0].Style.Fill.PatternType.ToString() | Should -Be 'Solid'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,25 +17,25 @@ Describe 'ConvertFrom-ExcelSheet / Export-ExcelSheet' {
|
||||
}
|
||||
Context "Exporting to CSV" {
|
||||
it "Exported the expected columns to a CSV file " {
|
||||
$firstText[0] | should be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
$SecondText[0] | should be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
$ThirdText[0] | should be '"Driver","date","FinishPosition","GridPosition"'
|
||||
$FourthText[0] | should be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
$firstText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
$SecondText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
$ThirdText[0] | Should -Be '"Driver","date","FinishPosition","GridPosition"'
|
||||
$FourthText[0] | Should -Be '"Race","Date","FinishPosition","Driver","GridPosition","Team","Points"'
|
||||
}
|
||||
it "Applied AsText, AsDate and Properties correctly " {
|
||||
$firstText[1] | should match '^"\w+","\d{5}","\d{1,2}","\w+ \w+","[1-9]\d?","\w+","\d{1,2}"$'
|
||||
$firstText[1] | Should -Match '^"\w+","\d{5}","\d{1,2}","\w+ \w+","[1-9]\d?","\w+","\d{1,2}"$'
|
||||
$date = $firstText[1] -replace '^.*(\d{5}).*$', '$1'
|
||||
$date = [datetime]::FromOADate($date).toString("D")
|
||||
$secondText[1] | should belike "*$date*"
|
||||
$secondText[1] | should match '"0\d","\w+","\d{1,2}"$'
|
||||
$ThirdText[1] | should match '^"\w+ \w+","#\d\d/\d\d/\d{4}#","\d","0\d"$'
|
||||
$FourthText[1] | should match '^"\w+","[012]\d'
|
||||
$secondText[1] | Should -Belike "*$date*"
|
||||
$secondText[1] | Should -Match '"0\d","\w+","\d{1,2}"$'
|
||||
$ThirdText[1] | Should -Match '^"\w+ \w+","#\d\d/\d\d/\d{4}#","\d","0\d"$'
|
||||
$FourthText[1] | Should -Match '^"\w+","[012]\d'
|
||||
}
|
||||
}
|
||||
Context "Export aliased to ConvertFrom" {
|
||||
it "Definded the alias name with " {
|
||||
(Get-Alias Export-ExcelSheet).source | should be "ImportExcel"
|
||||
(Get-Alias Export-ExcelSheet).Definition | should be "ConvertFrom-ExcelSheet"
|
||||
(Get-Alias Export-ExcelSheet).source | Should -Be "ImportExcel"
|
||||
(Get-Alias Export-ExcelSheet).Definition | Should -Be "ConvertFrom-ExcelSheet"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ Describe "ConvertFrom-ExcelToSQLInsert" {
|
||||
|
||||
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1
|
||||
|
||||
$actual | should be $expected
|
||||
$actual | Should -Be $expected
|
||||
}
|
||||
|
||||
It "Should have NULL".PadRight(90) {
|
||||
@@ -30,6 +30,6 @@ Describe "ConvertFrom-ExcelToSQLInsert" {
|
||||
|
||||
$actual = ConvertFrom-ExcelToSQLInsert -Path $xlFile Sheet1 -ConvertEmptyStringsToNull
|
||||
|
||||
$actual | should be $expected
|
||||
$actual | Should -Be $expected
|
||||
}
|
||||
}
|
||||
@@ -41,9 +41,9 @@ Describe "Copy-Worksheet" {
|
||||
$ws = $excel.Workbook.Worksheets["Processes"]
|
||||
}
|
||||
it "Inserted a worksheet " {
|
||||
$Excel.Workbook.Worksheets.count | Should be 2
|
||||
$ws | Should not benullorEmpty
|
||||
$ws.Dimension.Address | should be $ProcRange
|
||||
$Excel.Workbook.Worksheets.count | Should -Be 2
|
||||
$ws | Should -Not -BenullorEmpty
|
||||
$ws.Dimension.Address | Should -Be $ProcRange
|
||||
}
|
||||
}
|
||||
Context "Mixed types using a package object" {
|
||||
@@ -54,38 +54,38 @@ Describe "Copy-Worksheet" {
|
||||
$ws = $Excel.Workbook.Worksheets[3]
|
||||
}
|
||||
it "Copied a worksheet, giving the expected name, number of rows and number of columns " {
|
||||
$Excel.Workbook.Worksheets.count | Should be 3
|
||||
$ws | Should not benullorEmpty
|
||||
$ws.Name | Should be "CopyOfMixedTypes"
|
||||
$ws.Dimension.Columns | Should be 22
|
||||
$ws.Dimension.Rows | Should be 2
|
||||
$Excel.Workbook.Worksheets.count | Should -Be 3
|
||||
$ws | Should -Not -BenullorEmpty
|
||||
$ws.Name | Should -Be "CopyOfMixedTypes"
|
||||
$ws.Dimension.Columns | Should -Be 22
|
||||
$ws.Dimension.Rows | Should -Be 2
|
||||
}
|
||||
it "Copied the expected data into the worksheet " {
|
||||
$ws.Cells[2, 1].Value.Gettype().name | Should be 'DateTime'
|
||||
$ws.Cells[2, 2].Formula | Should be 'SUM(F2:G2)'
|
||||
$ws.Cells[2, 5].Value.GetType().name | Should be 'String'
|
||||
$ws.Cells[2, 6].Value.GetType().name | Should be 'String'
|
||||
$ws.Cells[2, 18].Value.GetType().name | Should be 'String'
|
||||
($ws.Cells[2, 11].Value -is [valuetype] ) | Should be $true
|
||||
($ws.Cells[2, 12].Value -is [valuetype] ) | Should be $true
|
||||
($ws.Cells[2, 13].Value -is [valuetype] ) | Should be $true
|
||||
$ws.Cells[2, 11].Value | Should beLessThan 0
|
||||
$ws.Cells[2, 12].Value | Should beLessThan 0
|
||||
$ws.Cells[2, 13].Value | Should beLessThan 0
|
||||
$ws.Cells[2, 1].Value.Gettype().name | Should -Be 'DateTime'
|
||||
$ws.Cells[2, 2].Formula | Should -Be 'SUM(F2:G2)'
|
||||
$ws.Cells[2, 5].Value.GetType().name | Should -Be 'String'
|
||||
$ws.Cells[2, 6].Value.GetType().name | Should -Be 'String'
|
||||
$ws.Cells[2, 18].Value.GetType().name | Should -Be 'String'
|
||||
($ws.Cells[2, 11].Value -is [valuetype] ) | Should -Be $true
|
||||
($ws.Cells[2, 12].Value -is [valuetype] ) | Should -Be $true
|
||||
($ws.Cells[2, 13].Value -is [valuetype] ) | Should -Be $true
|
||||
$ws.Cells[2, 11].Value | Should -BeLessThan 0
|
||||
$ws.Cells[2, 12].Value | Should -BeLessThan 0
|
||||
$ws.Cells[2, 13].Value | Should -BeLessThan 0
|
||||
if ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ",") {
|
||||
($ws.Cells[2, 8].Value -is [valuetype] ) | Should be $true
|
||||
$ws.Cells[2, 9].Value.GetType().name | Should be 'String'
|
||||
($ws.Cells[2, 8].Value -is [valuetype] ) | Should -Be $true
|
||||
$ws.Cells[2, 9].Value.GetType().name | Should -Be 'String'
|
||||
}
|
||||
elseif ((Get-Culture).NumberFormat.NumberGroupSeparator -EQ ".") {
|
||||
($ws.Cells[2, 9].Value -is [valuetype] ) | Should be $true
|
||||
$ws.Cells[2, 8].Value.GetType().name | Should be 'String'
|
||||
($ws.Cells[2, 9].Value -is [valuetype] ) | Should -Be $true
|
||||
$ws.Cells[2, 8].Value.GetType().name | Should -Be 'String'
|
||||
}
|
||||
($ws.Cells[2, 14].Value -is [valuetype] ) | Should be $true
|
||||
$ws.Cells[2, 15].Value.GetType().name | Should be 'String'
|
||||
$ws.Cells[2, 16].Value.GetType().name | Should be 'String'
|
||||
$ws.Cells[2, 17].Value.GetType().name | Should be 'String'
|
||||
($ws.Cells[2, 19].Value -is [valuetype] ) | Should be $true
|
||||
($ws.Cells[2, 20].Value -is [valuetype] ) | Should be $true
|
||||
($ws.Cells[2, 14].Value -is [valuetype] ) | Should -Be $true
|
||||
$ws.Cells[2, 15].Value.GetType().name | Should -Be 'String'
|
||||
$ws.Cells[2, 16].Value.GetType().name | Should -Be 'String'
|
||||
$ws.Cells[2, 17].Value.GetType().name | Should -Be 'String'
|
||||
($ws.Cells[2, 19].Value -is [valuetype] ) | Should -Be $true
|
||||
($ws.Cells[2, 20].Value -is [valuetype] ) | Should -Be $true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ Describe "Copy-Worksheet" {
|
||||
|
||||
$targetSheets | ForEach-Object { Remove-Worksheet -FullName $xlfile -WorksheetName $_ }
|
||||
|
||||
(Get-ExcelSheetInfo -Path $xlfile ).Count | Should Be 3
|
||||
(Get-ExcelSheetInfo -Path $xlfile ).Count | Should -Be 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,8 +136,8 @@ Describe "Copy-Worksheet" {
|
||||
}
|
||||
it "Should copy sheets piped into the command " {
|
||||
$excel = Open-ExcelPackage $xlfileArchive
|
||||
$excel.Workbook.Worksheets.Count | should be 5
|
||||
$excel.Workbook.Worksheets['1.3.2019'].Cells['A1'].Value | should be 'Hello World'
|
||||
$excel.Workbook.Worksheets.Count | should -be 5
|
||||
$excel.Workbook.Worksheets['1.3.2019'].Cells['A1'].Value | should -be 'Hello World'
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,45 +22,45 @@ Apple, New York, 1200,700
|
||||
$ws2 = $excel.Workbook.Worksheets[2]
|
||||
Context "Data Page" {
|
||||
It "Inserted the data and created the table " {
|
||||
$ws1.Tables[0] | Should not beNullOrEmpty
|
||||
$ws1.Tables[0].Address.Address | Should be "A1:D7"
|
||||
$ws1.Tables[0].StyleName | Should be "TableStyleMedium13"
|
||||
$ws1.Tables[0] | Should -Not -BeNullOrEmpty
|
||||
$ws1.Tables[0].Address.Address | Should -Be "A1:D7"
|
||||
$ws1.Tables[0].StyleName | Should -Be "TableStyleMedium13"
|
||||
}
|
||||
It "Applied conditional formatting " {
|
||||
$ws1.ConditionalFormatting[0] | Should not beNullOrEmpty
|
||||
$ws1.ConditionalFormatting[0].type.ToString() | Should be "DataBar"
|
||||
$ws1.ConditionalFormatting[0].Color.G | Should beGreaterThan 100
|
||||
$ws1.ConditionalFormatting[0].Color.R | Should beLessThan 100
|
||||
$ws1.ConditionalFormatting[0].Address.Address | Should be "C2:C7"
|
||||
$ws1.ConditionalFormatting[0] | Should -Not -BeNullOrEmpty
|
||||
$ws1.ConditionalFormatting[0].type.ToString() | Should -Be "DataBar"
|
||||
$ws1.ConditionalFormatting[0].Color.G | Should -BeGreaterThan 100
|
||||
$ws1.ConditionalFormatting[0].Color.R | Should -BeLessThan 100
|
||||
$ws1.ConditionalFormatting[0].Address.Address | Should -Be "C2:C7"
|
||||
}
|
||||
It "Added the chart " {
|
||||
$ws1.Drawings[0] | Should not beNullOrEmpty
|
||||
$ws1.Drawings[0].ChartType.ToString() | Should be "DoughNut"
|
||||
$ws1.Drawings[0].Series[0].Series | Should be "'Sheet1'!C2:C7"
|
||||
$ws1.Drawings[0] | Should -Not -BeNullOrEmpty
|
||||
$ws1.Drawings[0].ChartType.ToString() | Should -Be "DoughNut"
|
||||
$ws1.Drawings[0].Series[0].Series | Should -Be "'Sheet1'!C2:C7"
|
||||
}
|
||||
}
|
||||
Context "PivotTable" {
|
||||
it "Created the PivotTable on a new page " {
|
||||
$ws2 | Should not beNullOrEmpty
|
||||
$ws2.PivotTables[0] | Should not beNullOrEmpty
|
||||
$ws2.PivotTables[0].Fields.Count | Should be 4
|
||||
$ws2.PivotTables[0].DataFields[0].Format | Should be "$#,##0.00"
|
||||
$ws2.PivotTables[0].RowFields[0].Name | Should be "City"
|
||||
$ws2.PivotTables[0].ColumnFields[0].Name | Should be "Product"
|
||||
$ws2.PivotTables[0].RowGrandTotals | Should be $true
|
||||
$ws2.PivotTables[0].ColumGrandTotals | Should be $true #Epplus's mis-spelling of column not mine
|
||||
$ws2 | Should -Not -BeNullOrEmpty
|
||||
$ws2.PivotTables[0] | Should -Not -BeNullOrEmpty
|
||||
$ws2.PivotTables[0].Fields.Count | Should -Be 4
|
||||
$ws2.PivotTables[0].DataFields[0].Format | Should -Be "$#,##0.00"
|
||||
$ws2.PivotTables[0].RowFields[0].Name | Should -Be "City"
|
||||
$ws2.PivotTables[0].ColumnFields[0].Name | Should -Be "Product"
|
||||
$ws2.PivotTables[0].RowGrandTotals | Should -Be $true
|
||||
$ws2.PivotTables[0].ColumGrandTotals | Should -Be $true #Epplus's mis-spelling of column not mine
|
||||
}
|
||||
it "Made the PivotTable page active " {
|
||||
Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
|
||||
$ws2.View.TabSelected | Should be $true
|
||||
$ws2.View.TabSelected | Should -Be $true
|
||||
}
|
||||
it "Created the Pivot Chart " {
|
||||
$ws2.Drawings[0] | Should not beNullOrEmpty
|
||||
$ws2.Drawings[0].ChartType.ToString() | Should be ColumnClustered
|
||||
$ws2.Drawings[0].YAxis.MajorUnit | Should be 500
|
||||
$ws2.Drawings[0].YAxis.MinorUnit | Should be 100
|
||||
$ws2.Drawings[0].YAxis.Format | Should be "$#,##0"
|
||||
$ws2.Drawings[0].Legend.Position.ToString() | Should be "Bottom"
|
||||
$ws2.Drawings[0] | Should -Not -BeNullOrEmpty
|
||||
$ws2.Drawings[0].ChartType.ToString() | Should -Be ColumnClustered
|
||||
$ws2.Drawings[0].YAxis.MajorUnit | Should -Be 500
|
||||
$ws2.Drawings[0].YAxis.MinorUnit | Should -Be 100
|
||||
$ws2.Drawings[0].YAxis.Format | Should -Be "$#,##0"
|
||||
$ws2.Drawings[0].Legend.Position.ToString() | Should -Be "Bottom"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,84 +62,84 @@ Describe "Creating small named ranges with hyperlinks" {
|
||||
}
|
||||
Context "Creating hyperlinks" {
|
||||
it "Put the data into the sheet and created the expected named ranges " {
|
||||
$sheet.Dimension.Rows | should be $expectedRows
|
||||
$sheet.Dimension.Columns | should be $columns
|
||||
$sheet.Names.Count | should be ($columns + $results.Count)
|
||||
$sheet.Names[$results[0].Name] | should not benullorEmpty
|
||||
$sheet.Names[$results[-1].Name] | should not benullorEmpty
|
||||
$sheet.Dimension.Rows | Should -Be $expectedRows
|
||||
$sheet.Dimension.Columns | Should -Be $columns
|
||||
$sheet.Names.Count | Should -Be ($columns + $results.Count)
|
||||
$sheet.Names[$results[0].Name] | Should -Not -BenullorEmpty
|
||||
$sheet.Names[$results[-1].Name] | Should -Not -BenullorEmpty
|
||||
}
|
||||
it "Added hyperlinks to the named ranges " {
|
||||
$sheet.cells["a1"].Hyperlink.Display | should match $results[0].Name
|
||||
$sheet.cells["a1"].Hyperlink.ReferenceAddress | should match $results[0].Name
|
||||
$sheet.cells["a1"].Hyperlink.Display | Should -Match $results[0].Name
|
||||
$sheet.cells["a1"].Hyperlink.ReferenceAddress | Should -Match $results[0].Name
|
||||
}
|
||||
}
|
||||
Context "Adding calculated column" {
|
||||
It "Populated the cells with the right heading and formulas " {
|
||||
$sheet.Cells[( $results.Count), $columns] | Should benullorEmpty
|
||||
$sheet.Cells[(1 + $results.Count), $columns].Value | Should be "PlacesGained/Lost"
|
||||
$sheet.Cells[(2 + $results.Count), $columns].Formula | should be "GridPosition-FinishPosition"
|
||||
$sheet.Names["PlacesGained_Lost"] | should not benullorEmpty
|
||||
$sheet.Cells[( $results.Count), $columns] | Should -BenullorEmpty
|
||||
$sheet.Cells[(1 + $results.Count), $columns].Value | Should -Be "PlacesGained/Lost"
|
||||
$sheet.Cells[(2 + $results.Count), $columns].Formula | Should -Be "GridPosition-FinishPosition"
|
||||
$sheet.Names["PlacesGained_Lost"] | Should -Not -BenullorEmpty
|
||||
}
|
||||
It "Performed the calculation " {
|
||||
$placesMade = $Sheet.Cells[(2 + $results.Count), 5].value - $Sheet.Cells[(2 + $results.Count), 3].value
|
||||
$sheet.Cells[(2 + $results.Count), $columns].value | Should be $placesmade
|
||||
$sheet.Cells[(2 + $results.Count), $columns].value | Should -Be $placesmade
|
||||
}
|
||||
It "Applied ConditionalFormatting, including StopIfTrue, Priority " {
|
||||
$sheet.ConditionalFormatting[0].Address.Start.Column | should be $columns
|
||||
$sheet.ConditionalFormatting[0].Address.End.Column | should be $columns
|
||||
$sheet.ConditionalFormatting[0].Address.End.Row | should be $expectedRows
|
||||
$sheet.ConditionalFormatting[0].Address.Start.Row | should be ($results.Count + 1)
|
||||
$sheet.ConditionalFormatting[0].Icon3.Type.ToString() | Should be "Num"
|
||||
$sheet.ConditionalFormatting[0].Icon3.Value | Should be 1
|
||||
$sheet.ConditionalFormatting[1].Priority | Should be 1
|
||||
$sheet.ConditionalFormatting[1].StopIfTrue | Should be $true
|
||||
$sheet.ConditionalFormatting[0].Address.Start.Column | Should -Be $columns
|
||||
$sheet.ConditionalFormatting[0].Address.End.Column | Should -Be $columns
|
||||
$sheet.ConditionalFormatting[0].Address.End.Row | Should -Be $expectedRows
|
||||
$sheet.ConditionalFormatting[0].Address.Start.Row | Should -Be ($results.Count + 1)
|
||||
$sheet.ConditionalFormatting[0].Icon3.Type.ToString() | Should -Be "Num"
|
||||
$sheet.ConditionalFormatting[0].Icon3.Value | Should -Be 1
|
||||
$sheet.ConditionalFormatting[1].Priority | Should -Be 1
|
||||
$sheet.ConditionalFormatting[1].StopIfTrue | Should -Be $true
|
||||
}
|
||||
It "Applied ConditionalFormatting, including Reverse " {
|
||||
Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
|
||||
$sheet.ConditionalFormatting[3].LowValue.Color.R | Should begreaterThan 180
|
||||
$sheet.ConditionalFormatting[3].LowValue.Color.G | Should beLessThan 128
|
||||
$sheet.ConditionalFormatting[3].HighValue.Color.R | Should beLessThan 128
|
||||
$sheet.ConditionalFormatting[3].HighValue.Color.G | Should begreaterThan 180
|
||||
$sheet.ConditionalFormatting[3].LowValue.Color.R | Should -BegreaterThan 180
|
||||
$sheet.ConditionalFormatting[3].LowValue.Color.G | Should -BeLessThan 128
|
||||
$sheet.ConditionalFormatting[3].HighValue.Color.R | Should -BeLessThan 128
|
||||
$sheet.ConditionalFormatting[3].HighValue.Color.G | Should -BegreaterThan 180
|
||||
}
|
||||
}
|
||||
Context "Adding a table" {
|
||||
it "Created a table " {
|
||||
$sheet.tables[0] | Should not beNullOrEmpty
|
||||
$sheet.tables[0].Address.Start.Column | should be 1
|
||||
$sheet.tables[0].Address.End.Column | should be $columns
|
||||
$sheet.tables[0].Address.Start.row | should be ($results.Count + 1)
|
||||
$sheet.Tables[0].Address.End.Row | should be $expectedRows
|
||||
$sheet.Tables[0].StyleName | should be "TableStyleLight4"
|
||||
$sheet.Tables[0].ShowColumnStripes | should be $true
|
||||
$sheet.Tables[0].ShowRowStripes | should not be $true
|
||||
$sheet.tables[0] | Should -Not -BeNullOrEmpty
|
||||
$sheet.tables[0].Address.Start.Column | Should -Be 1
|
||||
$sheet.tables[0].Address.End.Column | Should -Be $columns
|
||||
$sheet.tables[0].Address.Start.row | Should -Be ($results.Count + 1)
|
||||
$sheet.Tables[0].Address.End.Row | Should -Be $expectedRows
|
||||
$sheet.Tables[0].StyleName | Should -Be "TableStyleLight4"
|
||||
$sheet.Tables[0].ShowColumnStripes | Should -Be $true
|
||||
$sheet.Tables[0].ShowRowStripes | Should -Not -Be $true
|
||||
}
|
||||
}
|
||||
Context "Adding Pivot tables" {
|
||||
it "Added a worksheet with a pivot table grouped by date " {
|
||||
$excel.Points1 | should not beNullOrEmpty
|
||||
$excel.Points1.PivotTables.Count | should be 1
|
||||
$excel.Points1 | Should -Not -BeNullOrEmpty
|
||||
$excel.Points1.PivotTables.Count | Should -Be 1
|
||||
$pt = $excel.Points1.PivotTables[0]
|
||||
$pt.RowFields.Count | should be 3
|
||||
$pt.RowFields[0].name | should be "Driver"
|
||||
$pt.RowFields[0].Grouping | should benullorEmpty
|
||||
$pt.RowFields[1].name | should be "years"
|
||||
$pt.RowFields[1].Grouping | should not benullorEmpty
|
||||
$pt.RowFields[2].name | should be "date"
|
||||
$pt.RowFields[2].Grouping | should not benullorEmpty
|
||||
$pt.RowFields.Count | Should -Be 3
|
||||
$pt.RowFields[0].name | Should -Be "Driver"
|
||||
$pt.RowFields[0].Grouping | Should -BenullorEmpty
|
||||
$pt.RowFields[1].name | Should -Be "years"
|
||||
$pt.RowFields[1].Grouping | Should -Not -BenullorEmpty
|
||||
$pt.RowFields[2].name | Should -Be "date"
|
||||
$pt.RowFields[2].Grouping | Should -Not -BenullorEmpty
|
||||
}
|
||||
it "Added a worksheet with a pivot table grouped by Number " {
|
||||
$excel.Places1 | should not beNullOrEmpty
|
||||
$excel.Places1.PivotTables.Count | should be 1
|
||||
$excel.Places1 | Should -Not -BeNullOrEmpty
|
||||
$excel.Places1.PivotTables.Count | Should -Be 1
|
||||
$pt = $excel.Places1.PivotTables[0]
|
||||
$pt.RowFields.Count | should be 2
|
||||
$pt.RowFields[0].name | should be "Driver"
|
||||
$pt.RowFields[0].Grouping | should benullorEmpty
|
||||
$pt.RowFields[0].SubTotalFunctions.ToString() | should be "None"
|
||||
$pt.RowFields[1].name | should be "FinishPosition"
|
||||
$pt.RowFields[1].Grouping | should not benullorEmpty
|
||||
$pt.RowFields[1].Grouping.Start | should be 1
|
||||
$pt.RowFields[1].Grouping.End | should be 25
|
||||
$pt.RowFields[1].Grouping.Interval | should be 3
|
||||
$pt.RowFields.Count | Should -Be 2
|
||||
$pt.RowFields[0].name | Should -Be "Driver"
|
||||
$pt.RowFields[0].Grouping | Should -BenullorEmpty
|
||||
$pt.RowFields[0].SubTotalFunctions.ToString() | Should -Be "None"
|
||||
$pt.RowFields[1].name | Should -Be "FinishPosition"
|
||||
$pt.RowFields[1].Grouping | Should -Not -BenullorEmpty
|
||||
$pt.RowFields[1].Grouping.Start | Should -Be 1
|
||||
$pt.RowFields[1].Grouping.End | Should -Be 25
|
||||
$pt.RowFields[1].Grouping.Interval | Should -Be 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,23 +6,23 @@ if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) {
|
||||
Describe "Check if Function aliases exist" {
|
||||
|
||||
It "Set-Column should exist".PadRight(90) {
|
||||
${Alias:Set-Column} | Should Not BeNullOrEmpty
|
||||
${Alias:Set-Column} | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Set-Row should exist".PadRight(90) {
|
||||
${Alias:Set-Row} | Should Not BeNullOrEmpty
|
||||
${Alias:Set-Row} | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It "Set-Format should exist".PadRight(90) {
|
||||
${Alias:Set-Format} | Should Not BeNullOrEmpty
|
||||
${Alias:Set-Format} | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
<#It "Merge-MulipleSheets should exist" {
|
||||
Get-Command Merge-MulipleSheets | Should Not Be $null
|
||||
Get-Command Merge-MulipleSheets | Should -Not -Be $null
|
||||
}
|
||||
#>
|
||||
It "New-ExcelChart should exist".PadRight(90) {
|
||||
${Alias:New-ExcelChart} | Should Not BeNullOrEmpty
|
||||
${Alias:New-ExcelChart} | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,13 +17,13 @@ $map = @{
|
||||
16384 = 'XFD'
|
||||
}
|
||||
|
||||
(Get-ExcelColumnName 26).columnName | Should be 'Z'
|
||||
(Get-ExcelColumnName 27).columnName | Should be 'AA'
|
||||
(Get-ExcelColumnName 28).columnNamee | Should be 'AB'
|
||||
(Get-ExcelColumnName 30).columnName | Should be 'AD'
|
||||
(Get-ExcelColumnName 48).columnName | Should be 'AV'
|
||||
(Get-ExcelColumnName 26).columnName | Should -Be 'Z'
|
||||
(Get-ExcelColumnName 27).columnName | Should -Be 'AA'
|
||||
(Get-ExcelColumnName 28).columnNamee | Should -Be 'AB'
|
||||
(Get-ExcelColumnName 30).columnName | Should -Be 'AD'
|
||||
(Get-ExcelColumnName 48).columnName | Should -Be 'AV'
|
||||
|
||||
1..16 | ForEach-Object {
|
||||
$number = $_ * 1024
|
||||
(Get-ExcelColumnName $number).columnName | Should be $map.$number
|
||||
(Get-ExcelColumnName $number).columnName | Should -Be $map.$number
|
||||
}
|
||||
|
||||
@@ -25,15 +25,15 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'A'
|
||||
$actualNames[1] | Should BeExactly 'B'
|
||||
$actualNames[2] | Should BeExactly 'C'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'A'
|
||||
$actualNames[1] | Should -BeExactly 'B'
|
||||
$actualNames[2] | Should -BeExactly 'C'
|
||||
|
||||
$actual.Count | Should Be 2
|
||||
$actual[0].A | Should BeExactly 'D'
|
||||
$actual[0].B | Should BeExactly 'E'
|
||||
$actual[0].C | Should BeExactly 'F'
|
||||
$actual.Count | Should -Be 2
|
||||
$actual[0].A | Should -BeExactly 'D'
|
||||
$actual[0].B | Should -BeExactly 'E'
|
||||
$actual[0].C | Should -BeExactly 'F'
|
||||
}
|
||||
|
||||
It "Import-Excel -NoHeader should have this shape" {
|
||||
@@ -41,12 +41,12 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'P1'
|
||||
$actualNames[1] | Should BeExactly 'P2'
|
||||
$actualNames[2] | Should BeExactly 'P3'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'P1'
|
||||
$actualNames[1] | Should -BeExactly 'P2'
|
||||
$actualNames[2] | Should -BeExactly 'P3'
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual.Count | Should -Be 3
|
||||
}
|
||||
|
||||
It "Import-Excel -HeaderName should have this shape" {
|
||||
@@ -54,20 +54,20 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'Q'
|
||||
$actualNames[1] | Should BeExactly 'R'
|
||||
$actualNames[2] | Should BeExactly 'S'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'Q'
|
||||
$actualNames[1] | Should -BeExactly 'R'
|
||||
$actualNames[2] | Should -BeExactly 'S'
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual.Count | Should -Be 3
|
||||
|
||||
$actual[0].Q | Should BeExactly 'A'
|
||||
$actual[0].R | Should BeExactly 'B'
|
||||
$actual[0].S | Should BeExactly 'C'
|
||||
$actual[0].Q | Should -BeExactly 'A'
|
||||
$actual[0].R | Should -BeExactly 'B'
|
||||
$actual[0].S | Should -BeExactly 'C'
|
||||
|
||||
$actual[1].Q | Should BeExactly 'D'
|
||||
$actual[1].R | Should BeExactly 'E'
|
||||
$actual[1].S | Should BeExactly 'F'
|
||||
$actual[1].Q | Should -BeExactly 'D'
|
||||
$actual[1].R | Should -BeExactly 'E'
|
||||
$actual[1].S | Should -BeExactly 'F'
|
||||
}
|
||||
|
||||
It "Should work with StartRow" {
|
||||
@@ -75,20 +75,20 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'Q'
|
||||
$actualNames[1] | Should BeExactly 'R'
|
||||
$actualNames[2] | Should BeExactly 'S'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'Q'
|
||||
$actualNames[1] | Should -BeExactly 'R'
|
||||
$actualNames[2] | Should -BeExactly 'S'
|
||||
|
||||
$actual.Count | Should Be 2
|
||||
$actual.Count | Should -Be 2
|
||||
|
||||
$actual[0].Q | Should BeExactly 'D'
|
||||
$actual[0].R | Should BeExactly 'E'
|
||||
$actual[0].S | Should BeExactly 'F'
|
||||
$actual[0].Q | Should -BeExactly 'D'
|
||||
$actual[0].R | Should -BeExactly 'E'
|
||||
$actual[0].S | Should -BeExactly 'F'
|
||||
|
||||
$actual[1].Q | Should BeExactly 'G'
|
||||
$actual[1].R | Should BeExactly 'H'
|
||||
$actual[1].S | Should BeExactly 'I'
|
||||
$actual[1].Q | Should -BeExactly 'G'
|
||||
$actual[1].R | Should -BeExactly 'H'
|
||||
$actual[1].S | Should -BeExactly 'I'
|
||||
|
||||
}
|
||||
|
||||
@@ -96,64 +96,64 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
$actual = @(Import-Excel $xlfile -NoHeader)
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'P1'
|
||||
$actualNames[1] | Should BeExactly 'P2'
|
||||
$actualNames[2] | Should BeExactly 'P3'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'P1'
|
||||
$actualNames[1] | Should -BeExactly 'P2'
|
||||
$actualNames[2] | Should -BeExactly 'P3'
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual.Count | Should -Be 3
|
||||
|
||||
$actual[0].P1 | Should BeExactly 'A'
|
||||
$actual[0].P2 | Should BeExactly 'B'
|
||||
$actual[0].P3 | Should BeExactly 'C'
|
||||
$actual[0].P1 | Should -BeExactly 'A'
|
||||
$actual[0].P2 | Should -BeExactly 'B'
|
||||
$actual[0].P3 | Should -BeExactly 'C'
|
||||
|
||||
$actual[1].P1 | Should BeExactly 'D'
|
||||
$actual[1].P2 | Should BeExactly 'E'
|
||||
$actual[1].P3 | Should BeExactly 'F'
|
||||
$actual[1].P1 | Should -BeExactly 'D'
|
||||
$actual[1].P2 | Should -BeExactly 'E'
|
||||
$actual[1].P3 | Should -BeExactly 'F'
|
||||
|
||||
$actual[2].P1 | Should BeExactly 'G'
|
||||
$actual[2].P2 | Should BeExactly 'H'
|
||||
$actual[2].P3 | Should BeExactly 'I'
|
||||
$actual[2].P1 | Should -BeExactly 'G'
|
||||
$actual[2].P2 | Should -BeExactly 'H'
|
||||
$actual[2].P3 | Should -BeExactly 'I'
|
||||
}
|
||||
|
||||
It "Should work with -NoHeader -DataOnly" {
|
||||
$actual = @(Import-Excel $xlfile -NoHeader -DataOnly)
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'P1'
|
||||
$actualNames[1] | Should BeExactly 'P2'
|
||||
$actualNames[2] | Should BeExactly 'P3'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'P1'
|
||||
$actualNames[1] | Should -BeExactly 'P2'
|
||||
$actualNames[2] | Should -BeExactly 'P3'
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual.Count | Should -Be 3
|
||||
|
||||
$actual[0].P1 | Should BeExactly 'A'
|
||||
$actual[0].P2 | Should BeExactly 'B'
|
||||
$actual[0].P3 | Should BeExactly 'C'
|
||||
$actual[0].P1 | Should -BeExactly 'A'
|
||||
$actual[0].P2 | Should -BeExactly 'B'
|
||||
$actual[0].P3 | Should -BeExactly 'C'
|
||||
|
||||
$actual[1].P1 | Should BeExactly 'D'
|
||||
$actual[1].P2 | Should BeExactly 'E'
|
||||
$actual[1].P3 | Should BeExactly 'F'
|
||||
$actual[1].P1 | Should -BeExactly 'D'
|
||||
$actual[1].P2 | Should -BeExactly 'E'
|
||||
$actual[1].P3 | Should -BeExactly 'F'
|
||||
|
||||
$actual[2].P1 | Should BeExactly 'G'
|
||||
$actual[2].P2 | Should BeExactly 'H'
|
||||
$actual[2].P3 | Should BeExactly 'I'
|
||||
$actual[2].P1 | Should -BeExactly 'G'
|
||||
$actual[2].P2 | Should -BeExactly 'H'
|
||||
$actual[2].P3 | Should -BeExactly 'I'
|
||||
}
|
||||
|
||||
It "Should work with -HeaderName -DataOnly -StartRow" {
|
||||
$actual = @(Import-Excel $xlfile -HeaderName 'Q', 'R', 'S' -DataOnly -StartRow 2)
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'Q'
|
||||
$actualNames[1] | Should BeExactly 'R'
|
||||
$actualNames[2] | Should BeExactly 'S'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'Q'
|
||||
$actualNames[1] | Should -BeExactly 'R'
|
||||
$actualNames[2] | Should -BeExactly 'S'
|
||||
|
||||
$actual.Count | Should Be 1
|
||||
$actual.Count | Should -Be 1
|
||||
|
||||
$actual[0].Q | Should BeExactly 'G'
|
||||
$actual[0].R | Should BeExactly 'H'
|
||||
$actual[0].S | Should BeExactly 'I'
|
||||
$actual[0].Q | Should -BeExactly 'G'
|
||||
$actual[0].R | Should -BeExactly 'H'
|
||||
$actual[0].S | Should -BeExactly 'I'
|
||||
}
|
||||
|
||||
It "Should" {
|
||||
@@ -180,17 +180,17 @@ Describe "Import-Excel on a sheet with no headings" {
|
||||
$actual = @(Import-Excel -Path $xlfile -DataOnly -HeaderName 'FirstName', 'SecondName', 'City' -StartRow 2)
|
||||
$actualNames = $actual[0].psobject.properties.name
|
||||
|
||||
$actualNames.Count | Should Be 3
|
||||
$actualNames[0] | Should BeExactly 'FirstName'
|
||||
$actualNames[1] | Should BeExactly 'SecondName'
|
||||
$actualNames[2] | Should BeExactly 'City'
|
||||
$actualNames.Count | Should -Be 3
|
||||
$actualNames[0] | Should -BeExactly 'FirstName'
|
||||
$actualNames[1] | Should -BeExactly 'SecondName'
|
||||
$actualNames[2] | Should -BeExactly 'City'
|
||||
|
||||
$actual.Count | Should Be 1
|
||||
$actual.Count | Should -Be 1
|
||||
|
||||
# Looks like -DataOnly does not handle empty columns
|
||||
# $actual[0].FirstName | Should BeExactly 'Jean-Claude'
|
||||
# $actual[0].SecondName | Should BeExactly 'Vandamme'
|
||||
# $actual[0].City | Should BeExactly 'Brussels'
|
||||
# $actual[0].FirstName | Should -BeExactly 'Jean-Claude'
|
||||
# $actual[0].SecondName | Should -BeExactly 'Vandamme'
|
||||
# $actual[0].City | Should -BeExactly 'Brussels'
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,19 +12,19 @@ Describe "Tests" {
|
||||
}
|
||||
It "Should have a valid manifest".PadRight(90){
|
||||
{try {Test-ModuleManifest -Path $PSScriptRoot\..\..\ImportExcel.psd1 -ErrorAction stop}
|
||||
catch {throw} } | should not throw
|
||||
catch {throw} } | Should -Not -Throw
|
||||
}
|
||||
It "Should have two items in the imported simple data".PadRight(90) {
|
||||
$data.count | Should be 2
|
||||
$data.count | Should -Be 2
|
||||
}
|
||||
|
||||
It "Should have items a and b in the imported simple data".PadRight(90) {
|
||||
$data[0].p1 | Should be "a"
|
||||
$data[1].p1 | Should be "b"
|
||||
$data[0].p1 | Should -Be "a"
|
||||
$data[1].p1 | Should -Be "b"
|
||||
}
|
||||
|
||||
It "Should read the simple xlsx in < 2100 milliseconds".PadRight(90) {
|
||||
$timer.TotalMilliseconds | should BeLessThan 2100
|
||||
$timer.TotalMilliseconds | Should -BeLessThan 2100
|
||||
}
|
||||
|
||||
It "Should read larger xlsx, 4k rows 1 col < 3000 milliseconds".PadRight(90) {
|
||||
@@ -32,7 +32,7 @@ Describe "Tests" {
|
||||
$null = Import-Excel $PSScriptRoot\LargerFile.xlsx
|
||||
}
|
||||
|
||||
$timer.TotalMilliseconds | should BeLessThan 3000
|
||||
$timer.TotalMilliseconds | Should -BeLessThan 3000
|
||||
}
|
||||
|
||||
It "Should be able to open, read and close as seperate actions".PadRight(90) {
|
||||
@@ -40,30 +40,30 @@ Describe "Tests" {
|
||||
$excel = Open-ExcelPackage $PSScriptRoot\Simple.xlsx
|
||||
$data = Import-Excel -ExcelPackage $excel
|
||||
Close-ExcelPackage -ExcelPackage $excel -NoSave}
|
||||
$timer.TotalMilliseconds | should BeLessThan 2100
|
||||
$data.count | Should be 2
|
||||
$data[0].p1 | Should be "a"
|
||||
$data[1].p1 | Should be "b"
|
||||
$timer.TotalMilliseconds | Should -BeLessThan 2100
|
||||
$data.count | Should -Be 2
|
||||
$data[0].p1 | Should -Be "a"
|
||||
$data[1].p1 | Should -Be "b"
|
||||
}
|
||||
|
||||
It "Should take Paths from parameter".PadRight(90) {
|
||||
$data = Import-Excel -Path (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName
|
||||
$data.count | Should be 4
|
||||
$data[0].cola | Should be 1
|
||||
$data[2].cola | Should be 5
|
||||
$data.count | Should -Be 4
|
||||
$data[0].cola | Should -Be 1
|
||||
$data[2].cola | Should -Be 5
|
||||
}
|
||||
|
||||
It "Should take Paths from pipeline".PadRight(90) {
|
||||
$data = (Get-ChildItem -Path $PSScriptRoot -Filter "TestData?.xlsx").FullName | Import-Excel
|
||||
$data.count | Should be 4
|
||||
$data[0].cola | Should be 1
|
||||
$data[2].cola | Should be 5
|
||||
$data.count | Should -Be 4
|
||||
$data[0].cola | Should -Be 1
|
||||
$data[2].cola | Should -Be 5
|
||||
}
|
||||
|
||||
It "Should support PipelineVariable".PadRight(90) {
|
||||
$data = Import-Excel $PSScriptRoot\Simple.xlsx -PipelineVariable 'Pv' | ForEach-Object { $Pv.p1 }
|
||||
$data.count | Should be 2
|
||||
$data[0] | Should be "a"
|
||||
$data[1] | Should be "b"
|
||||
$data.count | Should -Be 2
|
||||
$data[0] | Should -Be "a"
|
||||
$data[1] | Should -Be "b"
|
||||
}
|
||||
}
|
||||
@@ -46,41 +46,41 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
}
|
||||
Context "Array of processes" {
|
||||
it "Put the correct rows and columns into the sheet " {
|
||||
$sheet.Dimension.Rows | should be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | should be 5
|
||||
$sheet.cells["A1"].Value | should be "Name"
|
||||
$sheet.cells["E1"].Value | should be "StartTime"
|
||||
$sheet.cells["A3"].Value | should be $results[1].Name
|
||||
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | Should -Be 5
|
||||
$sheet.cells["A1"].Value | Should -Be "Name"
|
||||
$sheet.cells["E1"].Value | Should -Be "StartTime"
|
||||
$sheet.cells["A3"].Value | Should -Be $results[1].Name
|
||||
}
|
||||
it "Created a range for the whole sheet " {
|
||||
$sheet.Names[0].Name | should be "Whole"
|
||||
$sheet.Names[0].Start.Address | should be "A1"
|
||||
$sheet.Names[0].End.row | should be ($results.Count + 1)
|
||||
$sheet.Names[0].End.Column | should be 5
|
||||
$sheet.Names[0].Name | Should -Be "Whole"
|
||||
$sheet.Names[0].Start.Address | Should -Be "A1"
|
||||
$sheet.Names[0].End.row | Should -Be ($results.Count + 1)
|
||||
$sheet.Names[0].End.Column | Should -Be 5
|
||||
}
|
||||
it "Formatted date fields with date type " {
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
|
||||
}
|
||||
}
|
||||
$sheet = $excel.Sheet2
|
||||
Context "Table of processes" {
|
||||
it "Put the correct rows and columns into the sheet " {
|
||||
$sheet.Dimension.Rows | should be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | should be 5
|
||||
$sheet.cells["A1"].Value | should be "Name"
|
||||
$sheet.cells["E1"].Value | should be "StartTime"
|
||||
$sheet.cells["A3"].Value | should be $results[1].Name
|
||||
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | Should -Be 5
|
||||
$sheet.cells["A1"].Value | Should -Be "Name"
|
||||
$sheet.cells["E1"].Value | Should -Be "StartTime"
|
||||
$sheet.cells["A3"].Value | Should -Be $results[1].Name
|
||||
}
|
||||
it "Created named ranges for each column " {
|
||||
$sheet.Names.count | should be 5
|
||||
$sheet.Names[0].Name | should be "Name"
|
||||
$sheet.Names[1].Start.Address | should be "B2"
|
||||
$sheet.Names[2].End.row | should be ($results.Count + 1)
|
||||
$sheet.Names[3].End.Column | should be 4
|
||||
$sheet.Names[4].Start.Column | should be 5
|
||||
$sheet.Names.count | Should -Be 5
|
||||
$sheet.Names[0].Name | Should -Be "Name"
|
||||
$sheet.Names[1].Start.Address | Should -Be "B2"
|
||||
$sheet.Names[2].End.row | Should -Be ($results.Count + 1)
|
||||
$sheet.Names[3].End.Column | Should -Be 4
|
||||
$sheet.Names[4].Start.Column | Should -Be 5
|
||||
}
|
||||
it "Formatted date fields with date type " {
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,14 +88,14 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
$NowPkg = Open-ExcelPackage $NowPath1
|
||||
$sheet = $NowPkg.Sheet1
|
||||
it "Formatted data as a table by default " {
|
||||
$sheet.Tables.Count | should be 1
|
||||
$sheet.Tables.Count | Should -Be 1
|
||||
}
|
||||
Close-ExcelPackage -NoSave $NowPkg
|
||||
Remove-Item $NowPath1
|
||||
$NowPkg = Open-ExcelPackage $NowPath2
|
||||
$sheet = $NowPkg.Sheet1
|
||||
it "Did not data as a table when table:`$false was used " {
|
||||
$sheet.Tables.Count | should be 0
|
||||
$sheet.Tables.Count | Should -Be 0
|
||||
}
|
||||
Close-ExcelPackage -NoSave $NowPkg
|
||||
Remove-Item $NowPath2
|
||||
@@ -103,37 +103,37 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
$sheet = $excel.Sheet3
|
||||
Context "Table of processes via Send-SQLDataToExcel" {
|
||||
it "Put the correct data rows and columns into the sheet " {
|
||||
$sheet.Dimension.Rows | should be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | should be 5
|
||||
$sheet.cells["A1"].Value | should be "Name"
|
||||
$sheet.cells["E1"].Value | should be "StartTime"
|
||||
$sheet.cells["A3"].Value | should be $results[1].Name
|
||||
$sheet.Dimension.Rows | Should -Be ($results.Count + 1)
|
||||
$sheet.Dimension.Columns | Should -Be 5
|
||||
$sheet.cells["A1"].Value | Should -Be "Name"
|
||||
$sheet.cells["E1"].Value | Should -Be "StartTime"
|
||||
$sheet.cells["A3"].Value | Should -Be $results[1].Name
|
||||
}
|
||||
it "Created a table " {
|
||||
$sheet.Tables.count | should be 1
|
||||
$sheet.Tables[0].Columns[4].name | should be "StartTime"
|
||||
$sheet.Tables.count | Should -Be 1
|
||||
$sheet.Tables[0].Columns[4].name | Should -Be "StartTime"
|
||||
}
|
||||
it "Formatted date fields with date type " {
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | should be 22
|
||||
$sheet.Cells["E11"].Style.Numberformat.NumFmtID | Should -Be 22
|
||||
}
|
||||
it "Handled two data tables with the same name " {
|
||||
$sheet.Tables[0].Name | should be "Data_"
|
||||
$wvThree[0] | should match "is not unique"
|
||||
$sheet.Tables[0].Name | Should -Be "Data_"
|
||||
$wvThree[0] | Should -Match "is not unique"
|
||||
}
|
||||
}
|
||||
$Sheet = $excel.Sheet4
|
||||
Context "Zero-row Data Table sent with Send-SQLDataToExcel -Force" {
|
||||
it "Raised a warning and put the correct data headers into the sheet " {
|
||||
$sheet.Dimension.Rows | should be 1
|
||||
$sheet.Dimension.Columns | should be 5
|
||||
$sheet.cells["A1"].Value | should be "Name"
|
||||
$sheet.cells["E1"].Value | should be "StartTime"
|
||||
$sheet.cells["A3"].Value | should beNullOrEmpty
|
||||
$wvone[0] | should match "Zero"
|
||||
$sheet.Dimension.Rows | Should -Be 1
|
||||
$sheet.Dimension.Columns | Should -Be 5
|
||||
$sheet.cells["A1"].Value | Should -Be "Name"
|
||||
$sheet.cells["E1"].Value | Should -Be "StartTime"
|
||||
$sheet.cells["A3"].Value | Should -BeNullOrEmpty
|
||||
$wvone[0] | Should -Match "Zero"
|
||||
}
|
||||
it "Applied table formatting " {
|
||||
$sheet.Tables.Count | should be 1
|
||||
$sheet.Tables[0].Name | should be "Data"
|
||||
$sheet.Tables.Count | Should -Be 1
|
||||
$sheet.Tables[0].Name | Should -Be "Data"
|
||||
}
|
||||
|
||||
|
||||
@@ -141,8 +141,8 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
$Sheet = $excel.Sheet5
|
||||
Context "Zero-column Data Table handled by Send-SQLDataToExcel -Force" {
|
||||
it "Created a blank Sheet and raised a warning " {
|
||||
$sheet.Dimension | should beNullOrEmpty
|
||||
$wvTwo | should not beNullOrEmpty
|
||||
$sheet.Dimension | Should -BeNullOrEmpty
|
||||
$wvTwo | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
}
|
||||
@@ -150,32 +150,32 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
$excel = Open-ExcelPackage $path2
|
||||
Context "Send-SQLDataToExcel -append works correctly" {
|
||||
it "Works without table settings " {
|
||||
$excel.sheet1.Dimension.Address | should be "A1:E21"
|
||||
$excel.sheet1.cells[1,1].value | should be "Name"
|
||||
$excel.sheet1.cells[12,1].value | should be $excel.sheet1.cells[2,1].value
|
||||
$excel.sheet1.Tables.count | should be 0
|
||||
$excel.sheet1.Dimension.Address | Should -Be "A1:E21"
|
||||
$excel.sheet1.cells[1,1].value | Should -Be "Name"
|
||||
$excel.sheet1.cells[12,1].value | Should -Be $excel.sheet1.cells[2,1].value
|
||||
$excel.sheet1.Tables.count | Should -Be 0
|
||||
}
|
||||
it "Extends an existing table when appending " {
|
||||
$excel.sheet2.Dimension.Address | should be "A1:E21"
|
||||
$excel.sheet2.cells[1,2].value | should be "CPU"
|
||||
$excel.sheet2.cells[13,2].value | should be $excel.sheet2.cells[3,2].value
|
||||
$excel.sheet2.Tables.count | should be 1
|
||||
$excel.sheet2.Tables[0].name | should be "FirstLot"
|
||||
$excel.sheet2.Tables[0].StyleName | should be "TableStyleLight7"
|
||||
$excel.sheet2.Dimension.Address | Should -Be "A1:E21"
|
||||
$excel.sheet2.cells[1,2].value | Should -Be "CPU"
|
||||
$excel.sheet2.cells[13,2].value | Should -Be $excel.sheet2.cells[3,2].value
|
||||
$excel.sheet2.Tables.count | Should -Be 1
|
||||
$excel.sheet2.Tables[0].name | Should -Be "FirstLot"
|
||||
$excel.sheet2.Tables[0].StyleName | Should -Be "TableStyleLight7"
|
||||
}
|
||||
it "Creates a new table by name when appending " {
|
||||
$excel.sheet3.cells[1,3].value | should be "PM"
|
||||
$excel.sheet3.cells[14,3].value | should be $excel.sheet3.cells[4,3].value
|
||||
$excel.sheet3.Tables.count | should be 1
|
||||
$excel.sheet3.Tables[0].name | should be "SecondLot"
|
||||
$excel.sheet3.Tables[0].StyleName | should be "TableStyleMedium6"
|
||||
$excel.sheet3.cells[1,3].value | Should -Be "PM"
|
||||
$excel.sheet3.cells[14,3].value | Should -Be $excel.sheet3.cells[4,3].value
|
||||
$excel.sheet3.Tables.count | Should -Be 1
|
||||
$excel.sheet3.Tables[0].name | Should -Be "SecondLot"
|
||||
$excel.sheet3.Tables[0].StyleName | Should -Be "TableStyleMedium6"
|
||||
}
|
||||
it "Creates a new table by style when appending " {
|
||||
$excel.sheet4.cells[1,4].value | should be "Handles"
|
||||
$excel.sheet4.cells[15,4].value | should be $excel.sheet4.cells[5,4].value
|
||||
$excel.sheet4.Tables.count | should be 1
|
||||
$excel.sheet4.Tables[0].name | should be "Table1"
|
||||
$excel.sheet4.Tables[0].StyleName | should be "TableStyleDark5"
|
||||
$excel.sheet4.cells[1,4].value | Should -Be "Handles"
|
||||
$excel.sheet4.cells[15,4].value | Should -Be $excel.sheet4.cells[5,4].value
|
||||
$excel.sheet4.Tables.count | Should -Be 1
|
||||
$excel.sheet4.Tables[0].name | Should -Be "Table1"
|
||||
$excel.sheet4.Tables[0].StyleName | Should -Be "TableStyleDark5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,9 +183,9 @@ Describe "Exporting with -Inputobject, table handling, Send-SQL-Data. Checking I
|
||||
Context "Import As Text returns text values" {
|
||||
$x = Import-excel $path -WorksheetName sheet3 -AsText StartTime,hand* | Select-Object -last 1
|
||||
it "Had fields of type string, not date or int, where specified as ASText " {
|
||||
$x.Handles.GetType().Name | should be "String"
|
||||
$x.StartTime.GetType().Name | should be "String"
|
||||
$x.CPU.GetType().Name | should not be "String"
|
||||
$x.Handles.GetType().Name | Should -Be "String"
|
||||
$x.StartTime.GetType().Name | Should -Be "String"
|
||||
$x.CPU.GetType().Name | Should -Not -Be "String"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,52 +44,52 @@ Describe "Join Worksheet part 1" {
|
||||
}
|
||||
Context "Export-Excel setting spreadsheet visibility" {
|
||||
it "Hid the worksheets " {
|
||||
$excel.Workbook.Worksheets["Oxford"].Hidden | Should be 'Hidden'
|
||||
$excel.Workbook.Worksheets["Banbury"].Hidden | Should be 'Hidden'
|
||||
$excel.Workbook.Worksheets["Abingdon"].Hidden | Should be 'Hidden'
|
||||
$excel.Workbook.Worksheets["Oxford"].Hidden | Should -Be 'Hidden'
|
||||
$excel.Workbook.Worksheets["Banbury"].Hidden | Should -Be 'Hidden'
|
||||
$excel.Workbook.Worksheets["Abingdon"].Hidden | Should -Be 'Hidden'
|
||||
}
|
||||
it "Un-hid two of the worksheets " {
|
||||
$excel.Workbook.Worksheets["Total"].Hidden | Should be 'Visible'
|
||||
$excel.Workbook.Worksheets["SummaryPivot"].Hidden | Should be 'Visible'
|
||||
$excel.Workbook.Worksheets["Total"].Hidden | Should -Be 'Visible'
|
||||
$excel.Workbook.Worksheets["SummaryPivot"].Hidden | Should -Be 'Visible'
|
||||
}
|
||||
it "Activated the correct worksheet " {
|
||||
Set-ItResult -Pending -Because "Bug in EPPLus 4.5"
|
||||
$excel.Workbook.worksheets["SummaryPivot"].View.TabSelected | Should be $true
|
||||
$excel.Workbook.worksheets["Total"].View.TabSelected | Should be $false
|
||||
$excel.Workbook.worksheets["SummaryPivot"].View.TabSelected | Should -Be $true
|
||||
$excel.Workbook.worksheets["Total"].View.TabSelected | Should -Be $false
|
||||
}
|
||||
|
||||
}
|
||||
Context "Merging 3 blocks" {
|
||||
it "Created sheet of the right size with a title and a table " {
|
||||
$ws.Dimension.Address | Should be "A1:F16"
|
||||
$ws.Tables[0].Address.Address | Should be "A2:F16"
|
||||
$ws.Cells["A1"].Value | Should be "Store Sales Summary"
|
||||
$ws.Cells["A1"].Style.Font.Size | Should be 14
|
||||
$ws.Cells["A1"].Style.Font.Bold | Should be $True
|
||||
$ws.Cells["A1"].Style.Fill.BackgroundColor.Rgb | Should be "FFF0F8FF"
|
||||
$ws.Cells["A1"].Style.Fill.PatternType.ToString() | Should be "Solid"
|
||||
$ws.Tables[0].StyleName | Should be "TableStyleLight1"
|
||||
$ws.Cells["A2:F2"].Style.Font.Bold | Should be $True
|
||||
$ws.Dimension.Address | Should -Be "A1:F16"
|
||||
$ws.Tables[0].Address.Address | Should -Be "A2:F16"
|
||||
$ws.Cells["A1"].Value | Should -Be "Store Sales Summary"
|
||||
$ws.Cells["A1"].Style.Font.Size | Should -Be 14
|
||||
$ws.Cells["A1"].Style.Font.Bold | Should -Be $True
|
||||
$ws.Cells["A1"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFF0F8FF"
|
||||
$ws.Cells["A1"].Style.Fill.PatternType.ToString() | Should -Be "Solid"
|
||||
$ws.Tables[0].StyleName | Should -Be "TableStyleLight1"
|
||||
$ws.Cells["A2:F2"].Style.Font.Bold | Should -Be $True
|
||||
}
|
||||
it "Added a from column with the right heading " {
|
||||
$ws.Cells["F2" ].Value | Should be "Store"
|
||||
$ws.Cells["F3" ].Value | Should be "Oxford"
|
||||
$ws.Cells["F8" ].Value | Should be "Abingdon"
|
||||
$ws.Cells["F13"].Value | Should be "Banbury"
|
||||
$ws.Cells["F2" ].Value | Should -Be "Store"
|
||||
$ws.Cells["F3" ].Value | Should -Be "Oxford"
|
||||
$ws.Cells["F8" ].Value | Should -Be "Abingdon"
|
||||
$ws.Cells["F13"].Value | Should -Be "Banbury"
|
||||
}
|
||||
it "Filled in the data " {
|
||||
$ws.Cells["C3" ].Value | Should be $data1[0].quantity
|
||||
$ws.Cells["C8" ].Value | Should be $data2[0].quantity
|
||||
$ws.Cells["C13"].Value | Should be $data3[0].quantity
|
||||
$ws.Cells["C3" ].Value | Should -Be $data1[0].quantity
|
||||
$ws.Cells["C8" ].Value | Should -Be $data2[0].quantity
|
||||
$ws.Cells["C13"].Value | Should -Be $data3[0].quantity
|
||||
}
|
||||
it "Created the pivot table " {
|
||||
$pt | Should not beNullOrEmpty
|
||||
$pt.StyleName | Should be "PivotStyleMedium9"
|
||||
$pt.RowFields[0].Name | Should be "Store"
|
||||
$pt.ColumnFields[0].name | Should be "Product"
|
||||
$pt.DataFields[0].name | Should be "Sum of Total"
|
||||
$pc.ChartType | Should be "ColumnStacked"
|
||||
$pc.Title.text | Should be "Sales Breakdown"
|
||||
$pt | Should -Not -BeNullOrEmpty
|
||||
$pt.StyleName | Should -Be "PivotStyleMedium9"
|
||||
$pt.RowFields[0].Name | Should -Be "Store"
|
||||
$pt.ColumnFields[0].name | Should -Be "Product"
|
||||
$pt.DataFields[0].name | Should -Be "Sum of Total"
|
||||
$pc.ChartType | Should -Be "ColumnStacked"
|
||||
$pc.Title.text | Should -Be "Sales Breakdown"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,22 +109,22 @@ Describe "Join Worksheet part 2" {
|
||||
$ws = $excel.Workbook.Worksheets["Summary"]
|
||||
Context "Bringing 3 Unlinked blocks onto one page" {
|
||||
it "Hid the source worksheets " {
|
||||
$excel.Workbook.Worksheets[1].Hidden.tostring() | Should be "Hidden"
|
||||
$excel.Workbook.Worksheets[2].Hidden.tostring() | Should be "Hidden"
|
||||
$excel.Workbook.Worksheets[1].Hidden.tostring() | Should -Be "Hidden"
|
||||
$excel.Workbook.Worksheets[2].Hidden.tostring() | Should -Be "Hidden"
|
||||
}
|
||||
it "Created the Summary sheet with title, and block labels, and copied the correct data " {
|
||||
$ws.Cells["A1"].Value | Should be "Summary"
|
||||
$ws.Cells["A2"].Value | Should be $excel.Workbook.Worksheets[1].name
|
||||
$ws.Cells["A3"].Value | Should be $excel.Workbook.Worksheets[1].Cells["A1"].value
|
||||
$ws.Cells["A4"].Value | Should be $excel.Workbook.Worksheets[1].Cells["A2"].value
|
||||
$ws.Cells["B4"].Value | Should be $excel.Workbook.Worksheets[1].Cells["B2"].value
|
||||
$ws.Cells["A1"].Value | Should -Be "Summary"
|
||||
$ws.Cells["A2"].Value | Should -Be $excel.Workbook.Worksheets[1].name
|
||||
$ws.Cells["A3"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["A1"].value
|
||||
$ws.Cells["A4"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["A2"].value
|
||||
$ws.Cells["B4"].Value | Should -Be $excel.Workbook.Worksheets[1].Cells["B2"].value
|
||||
$nextRow = $excel.Workbook.Worksheets[1].Dimension.Rows + 3
|
||||
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].name
|
||||
$ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].name
|
||||
$nextRow ++
|
||||
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["A1"].value
|
||||
$ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["A1"].value
|
||||
$nextRow ++
|
||||
$ws.Cells["A$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["A2"].value
|
||||
$ws.Cells["B$NextRow"].Value | Should be $excel.Workbook.Worksheets[2].Cells["B2"].value
|
||||
$ws.Cells["A$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["A2"].value
|
||||
$ws.Cells["B$NextRow"].Value | Should -Be $excel.Workbook.Worksheets[2].Cells["B2"].value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,17 +15,17 @@ Describe "Password Support" {
|
||||
Get-Service | Select-Object -First 10 | Export-excel -password $password -Path $Path -DisplayPropertySet
|
||||
}
|
||||
it "Threw an error when the password was omitted " {
|
||||
{Open-ExcelPackage -Path $path } | should throw
|
||||
{Open-ExcelPackage -Path $path } | Should -Throw
|
||||
}
|
||||
it "Was able to append when the password was included " {
|
||||
{Get-Service | Select-Object -First 10 |
|
||||
Export-excel -password $password -Path $Path -Append } | should not throw
|
||||
Export-excel -password $password -Path $Path -Append } | Should -Not -Throw
|
||||
}
|
||||
it "Kept the password on the file when it was saved " {
|
||||
{Import-Excel $Path } | should throw
|
||||
{Import-Excel $Path } | Should -Throw
|
||||
}
|
||||
it "Could read the file when the password was included " {
|
||||
(Import-excel $path -Password $password).count | should be 20
|
||||
(Import-excel $path -Password $password).count | Should -Be 20
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,29 +10,29 @@
|
||||
|
||||
It "Should read local file".PadRight(90) {
|
||||
$actual = Import-Excel -Path ".\$($script:xlfileName)"
|
||||
$actual | Should Not Be $null
|
||||
$actual.Count | Should Be 1
|
||||
$actual | Should -Not -Be $null
|
||||
$actual.Count | Should -Be 1
|
||||
}
|
||||
|
||||
It "Should read with pwd".PadRight(90){
|
||||
$actual = Import-Excel -Path (Join-Path $PWD "$($script:xlfileName)")
|
||||
$actual | Should Not Be $null
|
||||
$actual | Should -Not -Be $null
|
||||
}
|
||||
|
||||
It "Should read with just a file name and resolve to cwd".PadRight(90){
|
||||
$actual = Import-Excel -Path "$($script:xlfileName)"
|
||||
$actual | Should Not Be $null
|
||||
$actual | Should -Not -Be $null
|
||||
}
|
||||
|
||||
It "Should fail for not found".PadRight(90){
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsx" } | Should Throw "'ExcelFileDoesNotExist.xlsx' file not found"
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsx" } | Should -Throw "'ExcelFileDoesNotExist.xlsx' file not found"
|
||||
}
|
||||
|
||||
It "Should fail for xls extension".PadRight(90){
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xls" } | Should Throw "Import-Excel does not support reading this extension type .xls"
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xls" } | Should -Throw "Import-Excel does not support reading this extension type .xls"
|
||||
}
|
||||
|
||||
It "Should fail for xlsxs extension".PadRight(90){
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsxs" } | Should Throw "Import-Excel does not support reading this extension type .xlsxs"
|
||||
{ Import-Excel -Path "ExcelFileDoesNotExist.xlsxs" } | Should -Throw "Import-Excel does not support reading this extension type .xlsxs"
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,15 @@ Apple, New York, 1200,700
|
||||
$ws = $ws = $excel.sheet1
|
||||
}
|
||||
it "Turned on protection for the sheet " {
|
||||
$ws.Protection.IsProtected | should be $true
|
||||
$ws.Protection.IsProtected | Should -Be $true
|
||||
}
|
||||
it "Set sheet-wide protection options " {
|
||||
$ws.Protection.AllowEditObject | should be $false
|
||||
$ws.Protection.AllowFormatRows | should be $true
|
||||
$ws.cells["a2"].Style.Locked | should be $true
|
||||
$ws.Protection.AllowEditObject | Should -Be $false
|
||||
$ws.Protection.AllowFormatRows | Should -Be $true
|
||||
$ws.cells["a2"].Style.Locked | Should -Be $true
|
||||
}
|
||||
it "Unprotected some cells " {
|
||||
$ws.cells["a1"].Style.Locked | should be $false
|
||||
$ws.cells["a1"].Style.Locked | Should -Be $false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,36 +6,36 @@ describe "Consistent passing of ranges." {
|
||||
Remove-Item -path $path -ErrorAction SilentlyContinue
|
||||
$excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -AutoNameRange -Title "Services on $Env:COMPUTERNAME"
|
||||
it "accepts named ranges, cells['name'], worksheet + Name, worksheet + column " {
|
||||
{Add-ConditionalFormatting $excel.Services.Names["Status"] -StrikeThru -RuleType ContainsText -ConditionValue "Stopped" } | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 1
|
||||
{Add-ConditionalFormatting $excel.Services.Cells["Name"] -Italic -RuleType ContainsText -ConditionValue "SVC" } | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 2
|
||||
{Add-ConditionalFormatting $excel.Services.Names["Status"] -StrikeThru -RuleType ContainsText -ConditionValue "Stopped" } | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 1
|
||||
{Add-ConditionalFormatting $excel.Services.Cells["Name"] -Italic -RuleType ContainsText -ConditionValue "SVC" } | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 2
|
||||
$warnvar = $null
|
||||
Add-ConditionalFormatting $excel.Services.Column(3) `
|
||||
-underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue
|
||||
$warnvar | should not beNullOrEmpty
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 2
|
||||
$warnvar | Should -Not -BeNullOrEmpty
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 2
|
||||
$warnvar = $null
|
||||
Add-ConditionalFormatting $excel.Services.Column(3) -Worksheet $excel.Services`
|
||||
-underline -RuleType ContainsText -ConditionValue "Windows" -WarningVariable warnvar -WarningAction SilentlyContinue
|
||||
$warnvar | should beNullOrEmpty
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 3
|
||||
$warnvar | Should -BeNullOrEmpty
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 3
|
||||
{Add-ConditionalFormatting "Status" -Worksheet $excel.Services `
|
||||
-ForeGroundColor ([System.Drawing.Color]::Green) -RuleType ContainsText -ConditionValue "Running"} | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 4
|
||||
-ForeGroundColor ([System.Drawing.Color]::Green) -RuleType ContainsText -ConditionValue "Running"} | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 4
|
||||
}
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
$excel = Get-Service | Export-Excel -Path $path -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME"
|
||||
it "accepts table, table.Address and worksheet + 'C:C' " {
|
||||
{Add-ConditionalFormatting $excel.Services.Tables[0] `
|
||||
-Italic -RuleType ContainsText -ConditionValue "Svc" } | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 1
|
||||
-Italic -RuleType ContainsText -ConditionValue "Svc" } | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 1
|
||||
{Add-ConditionalFormatting $excel.Services.Tables["ServiceTable"].Address `
|
||||
-Bold -RuleType ContainsText -ConditionValue "windows" } | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 2
|
||||
-Bold -RuleType ContainsText -ConditionValue "windows" } | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 2
|
||||
{Add-ConditionalFormatting -Worksheet $excel.Services -Address "a:a" `
|
||||
-RuleType ContainsText -ConditionValue "stopped" -ForeGroundColor ([System.Drawing.Color]::Red) } | Should not throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should be 3
|
||||
-RuleType ContainsText -ConditionValue "stopped" -ForeGroundColor ([System.Drawing.Color]::Red) } | Should -Not -Throw
|
||||
$excel.Services.ConditionalFormatting.Count | Should -Be 3
|
||||
}
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
}
|
||||
@@ -43,29 +43,29 @@ describe "Consistent passing of ranges." {
|
||||
Context "Formating (Set-ExcelRange or its alias Set-Format) " {
|
||||
it "accepts Named Range, cells['Name'], cells['A1:Z9'], row, Worksheet + 'A1:Z9'" {
|
||||
$excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoSize -DisplayPropertySet -RangeName servicerange -Title "Services on $Env:COMPUTERNAME"
|
||||
{Set-format $excel.Services.Names["serviceRange"] -Bold } | Should Not Throw
|
||||
$excel.Services.cells["B2"].Style.Font.Bold | Should be $true
|
||||
{Set-ExcelRange -Range $excel.Services.Cells["serviceRange"] -italic:$true } | Should not throw
|
||||
$excel.Services.cells["C3"].Style.Font.Italic | Should be $true
|
||||
{Set-format $excel.Services.Row(4) -underline -Bold:$false } | Should not throw
|
||||
$excel.Services.cells["A4"].Style.Font.UnderLine | Should be $true
|
||||
$excel.Services.cells["A4"].Style.Font.Bold | Should not be $true
|
||||
{Set-ExcelRange $excel.Services.Cells["A3:B3"] -StrikeThru } | Should not throw
|
||||
$excel.Services.cells["B3"].Style.Font.Strike | Should be $true
|
||||
{Set-ExcelRange -Worksheet $excel.Services -Range "A5:B6" -FontSize 8 } | Should not throw
|
||||
$excel.Services.cells["A5"].Style.Font.Size | Should be 8
|
||||
{Set-format $excel.Services.Names["serviceRange"] -Bold } | Should -Not -Throw
|
||||
$excel.Services.cells["B2"].Style.Font.Bold | Should -Be $true
|
||||
{Set-ExcelRange -Range $excel.Services.Cells["serviceRange"] -italic:$true } | Should -Not -Throw
|
||||
$excel.Services.cells["C3"].Style.Font.Italic | Should -Be $true
|
||||
{Set-format $excel.Services.Row(4) -underline -Bold:$false } | Should -Not -Throw
|
||||
$excel.Services.cells["A4"].Style.Font.UnderLine | Should -Be $true
|
||||
$excel.Services.cells["A4"].Style.Font.Bold | Should -Not -Be $true
|
||||
{Set-ExcelRange $excel.Services.Cells["A3:B3"] -StrikeThru } | Should -Not -Throw
|
||||
$excel.Services.cells["B3"].Style.Font.Strike | Should -Be $true
|
||||
{Set-ExcelRange -Worksheet $excel.Services -Range "A5:B6" -FontSize 8 } | Should -Not -Throw
|
||||
$excel.Services.cells["A5"].Style.Font.Size | Should -Be 8
|
||||
}
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
it "Accepts Table, Table.Address , worksheet + Name, Column," {
|
||||
$excel = Get-Service | Export-Excel -Path test2.xlsx -WorksheetName Services -PassThru -AutoNameRange -AutoSize -DisplayPropertySet -TableName servicetable -Title "Services on $Env:COMPUTERNAME"
|
||||
{Set-ExcelRange $excel.Services.Tables[0] -Italic } | Should not throw
|
||||
$excel.Services.cells["C3"].Style.Font.Italic | Should be $true
|
||||
{Set-format $excel.Services.Tables["ServiceTable"].Address -Underline } | Should not throw
|
||||
$excel.Services.cells["C3"].Style.Font.UnderLine | Should be $true
|
||||
{Set-ExcelRange -Worksheet $excel.Services -Range "Name" -Bold } | Should not throw
|
||||
$excel.Services.cells["B4"].Style.Font.Bold | Should be $true
|
||||
{$excel.Services.Column(3) | Set-ExcelRange -FontColor ([System.Drawing.Color]::Red) } | Should not throw
|
||||
$excel.Services.cells["C4"].Style.Font.Color.Rgb | Should be "FFFF0000"
|
||||
{Set-ExcelRange $excel.Services.Tables[0] -Italic } | Should -Not -Throw
|
||||
$excel.Services.cells["C3"].Style.Font.Italic | Should -Be $true
|
||||
{Set-format $excel.Services.Tables["ServiceTable"].Address -Underline } | Should -Not -Throw
|
||||
$excel.Services.cells["C3"].Style.Font.UnderLine | Should -Be $true
|
||||
{Set-ExcelRange -Worksheet $excel.Services -Range "Name" -Bold } | Should -Not -Throw
|
||||
$excel.Services.cells["B4"].Style.Font.Bold | Should -Be $true
|
||||
{$excel.Services.Column(3) | Set-ExcelRange -FontColor ([System.Drawing.Color]::Red) } | Should -Not -Throw
|
||||
$excel.Services.cells["C4"].Style.Font.Color.Rgb | Should -Be "FFFF0000"
|
||||
}
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
}
|
||||
@@ -77,24 +77,24 @@ describe "Consistent passing of ranges." {
|
||||
$end = $ws.Dimension.End.Address
|
||||
#can get a named ranged by name or index - starting at zero
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt0 -SourceRange $ws.Names[0]`
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt0"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt0"] | Should -Not -BeNullOrEmpty
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.Names["servicerange"]`
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt1"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt1"] | Should -Not -BeNullOrEmpty
|
||||
#Can specify the range for a pivot as NamedRange or Table or TableAddress or Worksheet + "A1:Z10" or worksheet + RangeName, or worksheet.cells["A1:Z10"] or worksheet.cells["RangeName"]
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange "servicerange" -SourceWorkSheet $ws `
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt2"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt2"] | Should -Not -BeNullOrEmpty
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt3 -SourceRange $ws.cells["servicerange"]`
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt3"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt3"] | Should -Not -BeNullOrEmpty
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt4 -SourceRange $ws.cells["A2:$end"]`
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt4"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt4"] | Should -Not -BeNullOrEmpty
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt5 -SourceRange "A2:$end" -SourceWorkSheet $ws `
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt5"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt5"] | Should -Not -BeNullOrEmpty
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
}
|
||||
it "Accepts Table, Table.Addres " {
|
||||
@@ -102,11 +102,11 @@ describe "Consistent passing of ranges." {
|
||||
$ws = $excel.Workbook.Worksheets["Services"] #can get a worksheet by name or index - starting at 1
|
||||
#Can get a table by name or -stating at zero. Can specify the range for a pivot as or Table or TableAddress
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt1 -SourceRange $ws.tables["servicetable"]`
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt1"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt1"] | Should -Not -BeNullOrEmpty
|
||||
{Add-PivotTable -ExcelPackage $excel -PivotTableName pt2 -SourceRange $ws.tables[0].Address `
|
||||
-PivotRows Status -PivotData Name } | Should not throw
|
||||
$excel.Workbook.Worksheets["pt2"] | Should not beNullOrEmpty
|
||||
-PivotRows Status -PivotData Name } | Should -Not -Throw
|
||||
$excel.Workbook.Worksheets["pt2"] | Should -Not -BeNullOrEmpty
|
||||
Close-ExcelPackage -NoSave $excel
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ John,20
|
||||
}
|
||||
|
||||
it "Should throw about the Path".PadRight(87) {
|
||||
{Remove-Worksheet} | Should throw 'Remove-Worksheet requires the and Excel file'
|
||||
{Remove-Worksheet} | Should -Throw 'Remove-Worksheet requires the and Excel file'
|
||||
}
|
||||
|
||||
it "Should delete Target2".PadRight(87) {
|
||||
@@ -37,10 +37,10 @@ John,20
|
||||
|
||||
$actual = Get-ExcelSheetInfo -Path $xlFile1
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual[0].Name | Should Be "Target1"
|
||||
$actual[1].Name | Should Be "Target3"
|
||||
$actual[2].Name | Should Be "Sheet1"
|
||||
$actual.Count | Should -Be 3
|
||||
$actual[0].Name | Should -Be "Target1"
|
||||
$actual[1].Name | Should -Be "Target3"
|
||||
$actual[2].Name | Should -Be "Sheet1"
|
||||
}
|
||||
|
||||
it "Should delete Sheet1".PadRight(87) {
|
||||
@@ -48,10 +48,10 @@ John,20
|
||||
|
||||
$actual = Get-ExcelSheetInfo -Path $xlFile1
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual[0].Name | Should Be "Target1"
|
||||
$actual[1].Name | Should Be "Target2"
|
||||
$actual[2].Name | Should Be "Target3"
|
||||
$actual.Count | Should -Be 3
|
||||
$actual[0].Name | Should -Be "Target1"
|
||||
$actual[1].Name | Should -Be "Target2"
|
||||
$actual[2].Name | Should -Be "Target3"
|
||||
}
|
||||
|
||||
it "Should delete multiple sheets".PadRight(87) {
|
||||
@@ -59,9 +59,9 @@ John,20
|
||||
|
||||
$actual = Get-ExcelSheetInfo -Path $xlFile1
|
||||
|
||||
$actual.Count | Should Be 2
|
||||
$actual[0].Name | Should Be "Target2"
|
||||
$actual[1].Name | Should Be "Target3"
|
||||
$actual.Count | Should -Be 2
|
||||
$actual[0].Name | Should -Be "Target2"
|
||||
$actual[1].Name | Should -Be "Target3"
|
||||
}
|
||||
|
||||
it "Should delete sheet from multiple workbooks".PadRight(87) {
|
||||
@@ -70,10 +70,10 @@ John,20
|
||||
|
||||
$actual = Get-ExcelSheetInfo -Path $xlFile1
|
||||
|
||||
$actual.Count | Should Be 3
|
||||
$actual[0].Name | Should Be "Target1"
|
||||
$actual[1].Name | Should Be "Target2"
|
||||
$actual[2].Name | Should Be "Target3"
|
||||
$actual.Count | Should -Be 3
|
||||
$actual[0].Name | Should -Be "Target1"
|
||||
$actual[1].Name | Should -Be "Target2"
|
||||
$actual[2].Name | Should -Be "Target3"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,16 +29,16 @@ Describe "Number format expansion and setting" {
|
||||
Context "Expand-NumberFormat function" {
|
||||
It "Expanded named number formats as expected " {
|
||||
$r = [regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol)
|
||||
Expand-NumberFormat 'Currency' | Should match "^[$r\(\)\[\] RED0#\?\-;,.]+$"
|
||||
Expand-NumberFormat 'Number' | Should be "0.00"
|
||||
Expand-NumberFormat 'Percentage' | Should be "0.00%"
|
||||
Expand-NumberFormat 'Scientific' | Should be "0.00E+00"
|
||||
Expand-NumberFormat 'Fraction' | Should be "# ?/?"
|
||||
Expand-NumberFormat 'Short Date' | Should be "mm-dd-yy"
|
||||
Expand-NumberFormat 'Short Time' | Should be "h:mm"
|
||||
Expand-NumberFormat 'Long Time' | Should be "h:mm:ss"
|
||||
Expand-NumberFormat 'Date-Time' | Should be "m/d/yy h:mm"
|
||||
Expand-NumberFormat 'Text' | Should be "@"
|
||||
Expand-NumberFormat 'Currency' | Should -Match "^[$r\(\)\[\] RED0#\?\-;,.]+$"
|
||||
Expand-NumberFormat 'Number' | Should -Be "0.00"
|
||||
Expand-NumberFormat 'Percentage' | Should -Be "0.00%"
|
||||
Expand-NumberFormat 'Scientific' | Should -Be "0.00E+00"
|
||||
Expand-NumberFormat 'Fraction' | Should -Be "# ?/?"
|
||||
Expand-NumberFormat 'Short Date' | Should -Be "mm-dd-yy"
|
||||
Expand-NumberFormat 'Short Time' | Should -Be "h:mm"
|
||||
Expand-NumberFormat 'Long Time' | Should -Be "h:mm:ss"
|
||||
Expand-NumberFormat 'Date-Time' | Should -Be "m/d/yy h:mm"
|
||||
Expand-NumberFormat 'Text' | Should -Be "@"
|
||||
}
|
||||
}
|
||||
Context "Apply-NumberFormat" {
|
||||
@@ -87,36 +87,36 @@ Describe "Number format expansion and setting" {
|
||||
}
|
||||
|
||||
It "Set formats which translate to the correct format ID " {
|
||||
$ws.Cells[ 1, 1].Style.Numberformat.NumFmtID | Should be 0 # Set as General
|
||||
$ws.Cells[20, 1].Style.Numberformat.NumFmtID | Should be 1 # Set as 0
|
||||
$ws.Cells[ 2, 1].Style.Numberformat.NumFmtID | Should be 2 # Set as "Number"
|
||||
$ws.Cells[21, 1].Style.Numberformat.NumFmtID | Should be 2 # Set as 0.00
|
||||
$ws.Cells[22, 1].Style.Numberformat.NumFmtID | Should be 3 # Set as #,##0
|
||||
$ws.Cells[23, 1].Style.Numberformat.NumFmtID | Should be 4 # Set as #,##0.00
|
||||
$ws.Cells[26, 1].Style.Numberformat.NumFmtID | Should be 9 # Set as 0%
|
||||
$ws.Cells[27, 1].Style.Numberformat.NumFmtID | Should be 10 # Set as 0.00%
|
||||
$ws.Cells[ 3, 1].Style.Numberformat.NumFmtID | Should be 10 # Set as "Percentage"
|
||||
$ws.Cells[28, 1].Style.Numberformat.NumFmtID | Should be 11 # Set as 0.00E+00
|
||||
$ws.Cells[ 4, 1].Style.Numberformat.NumFmtID | Should be 11 # Set as "Scientific"
|
||||
$ws.Cells[ 5, 1].Style.Numberformat.NumFmtID | Should be 12 # Set as "Fraction"
|
||||
$ws.Cells[29, 1].Style.Numberformat.NumFmtID | Should be 12 # Set as # ?/?
|
||||
$ws.Cells[30, 1].Style.Numberformat.NumFmtID | Should be 13 # Set as # ??/?
|
||||
$ws.Cells[ 6, 1].Style.Numberformat.NumFmtID | Should be 14 # Set as "Short date"
|
||||
$ws.Cells[17, 1].Style.Numberformat.NumFmtID | Should be 15 # Set as d-mmm-yy
|
||||
$ws.Cells[18, 1].Style.Numberformat.NumFmtID | Should be 16 # Set as d-mmm
|
||||
$ws.Cells[19, 1].Style.Numberformat.NumFmtID | Should be 17 # Set as mmm-yy
|
||||
$ws.Cells[12, 1].Style.Numberformat.NumFmtID | Should be 18 # Set as h:mm AM/PM
|
||||
$ws.Cells[13, 1].Style.Numberformat.NumFmtID | Should be 19 # Set as h:mm:ss AM/PM
|
||||
$ws.Cells[ 7, 1].Style.Numberformat.NumFmtID | Should be 20 # Set as "Short time"
|
||||
$ws.Cells[ 8, 1].Style.Numberformat.NumFmtID | Should be 21 # Set as "Long time"
|
||||
$ws.Cells[ 9, 1].Style.Numberformat.NumFmtID | Should be 22 # Set as "Date-time"
|
||||
$ws.Cells[14, 1].Style.Numberformat.NumFmtID | Should be 45 # Set as mm:ss
|
||||
$ws.Cells[15, 1].Style.Numberformat.NumFmtID | Should be 46 # Set as [h]:mm:ss
|
||||
$ws.Cells[16, 1].Style.Numberformat.NumFmtID | Should be 47 # Set as mmss.0
|
||||
$ws.Cells[11, 1].Style.Numberformat.NumFmtID | Should be 49 # Set as "Text"
|
||||
$ws.Cells[31, 1].Style.Numberformat.NumFmtID | Should be 49 # Set as @
|
||||
$ws.Cells[24, 1].Style.Numberformat.Format | Should be '#,' # Whole thousands
|
||||
$ws.Cells[25, 1].Style.Numberformat.Format | Should be '#.0,,' # Millions
|
||||
$ws.Cells[ 1, 1].Style.Numberformat.NumFmtID | Should -Be 0 # Set as General
|
||||
$ws.Cells[20, 1].Style.Numberformat.NumFmtID | Should -Be 1 # Set as 0
|
||||
$ws.Cells[ 2, 1].Style.Numberformat.NumFmtID | Should -Be 2 # Set as "Number"
|
||||
$ws.Cells[21, 1].Style.Numberformat.NumFmtID | Should -Be 2 # Set as 0.00
|
||||
$ws.Cells[22, 1].Style.Numberformat.NumFmtID | Should -Be 3 # Set as #,##0
|
||||
$ws.Cells[23, 1].Style.Numberformat.NumFmtID | Should -Be 4 # Set as #,##0.00
|
||||
$ws.Cells[26, 1].Style.Numberformat.NumFmtID | Should -Be 9 # Set as 0%
|
||||
$ws.Cells[27, 1].Style.Numberformat.NumFmtID | Should -Be 10 # Set as 0.00%
|
||||
$ws.Cells[ 3, 1].Style.Numberformat.NumFmtID | Should -Be 10 # Set as "Percentage"
|
||||
$ws.Cells[28, 1].Style.Numberformat.NumFmtID | Should -Be 11 # Set as 0.00E+00
|
||||
$ws.Cells[ 4, 1].Style.Numberformat.NumFmtID | Should -Be 11 # Set as "Scientific"
|
||||
$ws.Cells[ 5, 1].Style.Numberformat.NumFmtID | Should -Be 12 # Set as "Fraction"
|
||||
$ws.Cells[29, 1].Style.Numberformat.NumFmtID | Should -Be 12 # Set as # ?/?
|
||||
$ws.Cells[30, 1].Style.Numberformat.NumFmtID | Should -Be 13 # Set as # ??/?
|
||||
$ws.Cells[ 6, 1].Style.Numberformat.NumFmtID | Should -Be 14 # Set as "Short date"
|
||||
$ws.Cells[17, 1].Style.Numberformat.NumFmtID | Should -Be 15 # Set as d-mmm-yy
|
||||
$ws.Cells[18, 1].Style.Numberformat.NumFmtID | Should -Be 16 # Set as d-mmm
|
||||
$ws.Cells[19, 1].Style.Numberformat.NumFmtID | Should -Be 17 # Set as mmm-yy
|
||||
$ws.Cells[12, 1].Style.Numberformat.NumFmtID | Should -Be 18 # Set as h:mm AM/PM
|
||||
$ws.Cells[13, 1].Style.Numberformat.NumFmtID | Should -Be 19 # Set as h:mm:ss AM/PM
|
||||
$ws.Cells[ 7, 1].Style.Numberformat.NumFmtID | Should -Be 20 # Set as "Short time"
|
||||
$ws.Cells[ 8, 1].Style.Numberformat.NumFmtID | Should -Be 21 # Set as "Long time"
|
||||
$ws.Cells[ 9, 1].Style.Numberformat.NumFmtID | Should -Be 22 # Set as "Date-time"
|
||||
$ws.Cells[14, 1].Style.Numberformat.NumFmtID | Should -Be 45 # Set as mm:ss
|
||||
$ws.Cells[15, 1].Style.Numberformat.NumFmtID | Should -Be 46 # Set as [h]:mm:ss
|
||||
$ws.Cells[16, 1].Style.Numberformat.NumFmtID | Should -Be 47 # Set as mmss.0
|
||||
$ws.Cells[11, 1].Style.Numberformat.NumFmtID | Should -Be 49 # Set as "Text"
|
||||
$ws.Cells[31, 1].Style.Numberformat.NumFmtID | Should -Be 49 # Set as @
|
||||
$ws.Cells[24, 1].Style.Numberformat.Format | Should -Be '#,' # Whole thousands
|
||||
$ws.Cells[25, 1].Style.Numberformat.Format | Should -Be '#.0,,' # Millions
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,70 +155,70 @@ Describe "Set-ExcelColumn, Set-ExcelRow and Set-ExcelRange" {
|
||||
}
|
||||
Context "Set-ExcelRow and Set-ExcelColumn" {
|
||||
it "Set a row and a column to have zero width/height " {
|
||||
$r | Should not beNullorEmpty
|
||||
# $c | Should not beNullorEmpty ## can't see why but this test breaks in appveyor
|
||||
$ws.Column(1).width | Should be 0
|
||||
$ws.Row(5).height | Should be 0
|
||||
$r | Should -Not -BeNullorEmpty
|
||||
# $c | Should -Not -BeNullorEmpty ## can't see why but this test breaks in appveyor
|
||||
$ws.Column(1).width | Should -Be 0
|
||||
$ws.Row(5).height | Should -Be 0
|
||||
}
|
||||
it "Set a column formula, with numberformat, color, bold face and alignment " {
|
||||
$ws.Cells["e2"].Formula | Should be "Quantity*Price"
|
||||
$ws.Cells["e2"].Value | Should be 147.63
|
||||
$ws.Cells["e2"].Style.Font.Color.rgb | Should be "FF0000FF"
|
||||
$ws.Cells["e2"].Style.Font.Bold | Should be $true
|
||||
$ws.Cells["e2"].Style.Font.VerticalAlign | Should be "None"
|
||||
$ws.Cells["e2"].Style.Numberformat.format | Should be "£#,###.00"
|
||||
$ws.Cells["e2"].Style.HorizontalAlignment | Should be "Right"
|
||||
$ws.Cells["e2"].Formula | Should -Be "Quantity*Price"
|
||||
$ws.Cells["e2"].Value | Should -Be 147.63
|
||||
$ws.Cells["e2"].Style.Font.Color.rgb | Should -Be "FF0000FF"
|
||||
$ws.Cells["e2"].Style.Font.Bold | Should -Be $true
|
||||
$ws.Cells["e2"].Style.Font.VerticalAlign | Should -Be "None"
|
||||
$ws.Cells["e2"].Style.Numberformat.format | Should -Be "£#,###.00"
|
||||
$ws.Cells["e2"].Style.HorizontalAlignment | Should -Be "Right"
|
||||
}
|
||||
}
|
||||
Context "Other formatting" {
|
||||
it "Trapped an attempt to hide a range instead of a Row/Column " {
|
||||
$BadHideWarnvar | Should not beNullOrEmpty
|
||||
$BadHideWarnvar | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
it "Set and calculated a row formula with border font size and underline " {
|
||||
$ws.Cells["b7"].Style.Border.Top.Style | Should be "None"
|
||||
$ws.Cells["F7"].Style.Border.Top.Style | Should be "None"
|
||||
$ws.Cells["C7"].Style.Border.Top.Style | Should be "Thin"
|
||||
$ws.Cells["C7"].Style.Border.Bottom.Style | Should be "Thin"
|
||||
$ws.Cells["C7"].Style.Border.Right.Style | Should be "None"
|
||||
$ws.Cells["C7"].Style.Border.Left.Style | Should be "Thin"
|
||||
$ws.Cells["E7"].Style.Border.Left.Style | Should be "None"
|
||||
$ws.Cells["E7"].Style.Border.Right.Style | Should be "Thin"
|
||||
$ws.Cells["C7"].Style.Font.size | Should be 14
|
||||
$ws.Cells["C7"].Formula | Should be "sum(C2:C6)"
|
||||
$ws.Cells["C7"].value | Should be 81
|
||||
$ws.Cells["C7"].Style.Font.UnderLine | Should be $true
|
||||
$ws.Cells["C6"].Style.Font.UnderLine | Should be $false
|
||||
$ws.Cells["b7"].Style.Border.Top.Style | Should -Be "None"
|
||||
$ws.Cells["F7"].Style.Border.Top.Style | Should -Be "None"
|
||||
$ws.Cells["C7"].Style.Border.Top.Style | Should -Be "Thin"
|
||||
$ws.Cells["C7"].Style.Border.Bottom.Style | Should -Be "Thin"
|
||||
$ws.Cells["C7"].Style.Border.Right.Style | Should -Be "None"
|
||||
$ws.Cells["C7"].Style.Border.Left.Style | Should -Be "Thin"
|
||||
$ws.Cells["E7"].Style.Border.Left.Style | Should -Be "None"
|
||||
$ws.Cells["E7"].Style.Border.Right.Style | Should -Be "Thin"
|
||||
$ws.Cells["C7"].Style.Font.size | Should -Be 14
|
||||
$ws.Cells["C7"].Formula | Should -Be "sum(C2:C6)"
|
||||
$ws.Cells["C7"].value | Should -Be 81
|
||||
$ws.Cells["C7"].Style.Font.UnderLine | Should -Be $true
|
||||
$ws.Cells["C6"].Style.Font.UnderLine | Should -Be $false
|
||||
}
|
||||
it "Set custom font, size, text-wrapping, alignment, superscript, border and Fill " {
|
||||
$ws.Cells["b3"].Style.Border.Left.Color.Rgb | Should be "FFFF0000"
|
||||
$ws.Cells["b3"].Style.Border.Left.Style | Should be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Right.Style | Should be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Top.Style | Should be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Bottom.Style | Should be "Thick"
|
||||
$ws.Cells["b3"].Style.Font.Strike | Should be $true
|
||||
$ws.Cells["e1"].Style.Font.Color.Rgb | Should be "ff000000"
|
||||
$ws.Cells["e1"].Style.Font.Bold | Should be $false
|
||||
$ws.Cells["e1"].Style.Font.Name | Should be "Courier New"
|
||||
$ws.Cells["e1"].Style.Font.Size | Should be 9
|
||||
$ws.Cells["e3"].Style.Font.VerticalAlign | Should be "Superscript"
|
||||
$ws.Cells["e3"].Style.HorizontalAlignment | Should be "Left"
|
||||
$ws.Cells["C6"].Style.WrapText | Should be $false
|
||||
$ws.Cells["e7"].Style.WrapText | Should be $true
|
||||
$ws.Cells["e7"].Style.Fill.BackgroundColor.Rgb | Should be "FFF0F8FF"
|
||||
$ws.Cells["e7"].Style.Fill.PatternColor.Rgb | Should be "FFFF0000"
|
||||
$ws.Cells["e7"].Style.Fill.PatternType | Should be "DarkTrellis"
|
||||
$ws.Cells["b3"].Style.Border.Left.Color.Rgb | Should -Be "FFFF0000"
|
||||
$ws.Cells["b3"].Style.Border.Left.Style | Should -Be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Right.Style | Should -Be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Top.Style | Should -Be "Thick"
|
||||
$ws.Cells["b3"].Style.Border.Bottom.Style | Should -Be "Thick"
|
||||
$ws.Cells["b3"].Style.Font.Strike | Should -Be $true
|
||||
$ws.Cells["e1"].Style.Font.Color.Rgb | Should -Be "ff000000"
|
||||
$ws.Cells["e1"].Style.Font.Bold | Should -Be $false
|
||||
$ws.Cells["e1"].Style.Font.Name | Should -Be "Courier New"
|
||||
$ws.Cells["e1"].Style.Font.Size | Should -Be 9
|
||||
$ws.Cells["e3"].Style.Font.VerticalAlign | Should -Be "Superscript"
|
||||
$ws.Cells["e3"].Style.HorizontalAlignment | Should -Be "Left"
|
||||
$ws.Cells["C6"].Style.WrapText | Should -Be $false
|
||||
$ws.Cells["e7"].Style.WrapText | Should -Be $true
|
||||
$ws.Cells["e7"].Style.Fill.BackgroundColor.Rgb | Should -Be "FFF0F8FF"
|
||||
$ws.Cells["e7"].Style.Fill.PatternColor.Rgb | Should -Be "FFFF0000"
|
||||
$ws.Cells["e7"].Style.Fill.PatternType | Should -Be "DarkTrellis"
|
||||
}
|
||||
}
|
||||
|
||||
Context "Set-ExcelRange value setting " {
|
||||
it "Inserted a formula " {
|
||||
$ws.Cells["D7"].Formula | Should be "E7/C7"
|
||||
$ws.Cells["D7"].Formula | Should -Be "E7/C7"
|
||||
}
|
||||
it "Inserted a value " {
|
||||
$ws.Cells["B7"].Value | Should be "Total"
|
||||
$ws.Cells["B7"].Value | Should -Be "Total"
|
||||
}
|
||||
it "Inserted a date with localized date-time format " {
|
||||
$ws.Cells["B8"].Style.Numberformat.NumFmtID | Should be 22
|
||||
$ws.Cells["B8"].Style.Numberformat.NumFmtID | Should -Be 22
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,27 +249,27 @@ Describe "Set-ExcelColumn, Set-ExcelRow and Set-ExcelRange" {
|
||||
$ws = $excel.Workbook.Worksheets["Sheet1"]
|
||||
}
|
||||
It "Inserted Hyperlinks " {
|
||||
$ws.Cells["D2"].Hyperlink | Should not beNullorEmpty
|
||||
$ws.Cells["D2"].Style.Font.UnderLine | Should be $true
|
||||
$ws.Cells["D2"].Hyperlink | Should -Not -BeNullorEmpty
|
||||
$ws.Cells["D2"].Style.Font.UnderLine | Should -Be $true
|
||||
}
|
||||
It "Inserted and formatted Dates " {
|
||||
$ws.Cells["C2"].Value.GetType().name | should be "DateTime"
|
||||
$ws.Cells["C2"].Style.Numberformat.NumFmtID | should be 14
|
||||
$ws.Cells["E2"].Value.GetType().name | should be "DateTime"
|
||||
$ws.Cells["E2"].Style.Numberformat.NumFmtID | should be 14
|
||||
$ws.Cells["C2"].Value.GetType().name | Should -Be "DateTime"
|
||||
$ws.Cells["C2"].Style.Numberformat.NumFmtID | Should -Be 14
|
||||
$ws.Cells["E2"].Value.GetType().name | Should -Be "DateTime"
|
||||
$ws.Cells["E2"].Style.Numberformat.NumFmtID | Should -Be 14
|
||||
}
|
||||
It "Inserted Formulas " {
|
||||
$ws.Cells["F2"].Formula | Should not beNullorEmpty
|
||||
$ws.Cells["F2"].Formula | Should -Not -BeNullorEmpty
|
||||
}
|
||||
It "Created Named ranges " {
|
||||
$ws.Names.Count | Should be 6
|
||||
$ws.Names["Age"] | Should not beNullorEmpty
|
||||
$ws.Names["Age"].Start.Column | Should be 6
|
||||
$ws.Names["Age"].Start.Row | Should be 2
|
||||
$ws.Names["Age"].End.Row | Should be 7
|
||||
$ws.names[0].name | Should be "Name"
|
||||
$ws.Names[0].Start.Column | Should be 1
|
||||
$ws.Names[0].Start.Row | Should be 2
|
||||
$ws.Names.Count | Should -Be 6
|
||||
$ws.Names["Age"] | Should -Not -BeNullorEmpty
|
||||
$ws.Names["Age"].Start.Column | Should -Be 6
|
||||
$ws.Names["Age"].Start.Row | Should -Be 2
|
||||
$ws.Names["Age"].End.Row | Should -Be 7
|
||||
$ws.names[0].name | Should -Be "Name"
|
||||
$ws.Names[0].Start.Column | Should -Be 1
|
||||
$ws.Names[0].Start.Row | Should -Be 2
|
||||
}
|
||||
|
||||
}
|
||||
@@ -286,9 +286,9 @@ Describe "Conditional Formatting" {
|
||||
}
|
||||
Context "Using a pre-prepared 3 Arrows rule" {
|
||||
it "Set the right type, IconSet and range " {
|
||||
$ws.ConditionalFormatting[0].IconSet | Should be "Arrows"
|
||||
$ws.ConditionalFormatting[0].Address.Address | Should be "c:c"
|
||||
$ws.ConditionalFormatting[0].Type.ToString() | Should be "ThreeIconSet"
|
||||
$ws.ConditionalFormatting[0].IconSet | Should -Be "Arrows"
|
||||
$ws.ConditionalFormatting[0].Address.Address | Should -Be "c:c"
|
||||
$ws.ConditionalFormatting[0].Type.ToString() | Should -Be "ThreeIconSet"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -329,8 +329,8 @@ Sold
|
||||
|
||||
$ws = $excel.Workbook.Worksheets["Sheet1"]
|
||||
|
||||
$ws.Names.Count | Should Be 1
|
||||
$ws.Names[0].Name | Should Be 'Sold'
|
||||
$ws.Names.Count | Should -Be 1
|
||||
$ws.Names[0].Name | Should -Be 'Sold'
|
||||
}
|
||||
|
||||
it "Should have a more than a single item as a named range " {
|
||||
@@ -344,9 +344,9 @@ Sold,ID
|
||||
|
||||
$ws = $excel.Workbook.Worksheets["Sheet1"]
|
||||
|
||||
$ws.Names.Count | Should Be 2
|
||||
$ws.Names[0].Name | Should Be 'Sold'
|
||||
$ws.Names[1].Name | Should Be 'ID'
|
||||
$ws.Names.Count | Should -Be 2
|
||||
$ws.Names[0].Name | Should -Be 'Sold'
|
||||
$ws.Names[1].Name | Should -Be 'ID'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,20 +368,20 @@ Describe "Table Formatting" {
|
||||
}
|
||||
Context "Setting and not clearing when Export-Excel touches the file again." {
|
||||
it "Set the Table Options " {
|
||||
$ws1.Tables[0].Address.Address | should be "A1:E16"
|
||||
$ws1.Tables[0].Name | should be "HardwareTable"
|
||||
$ws1.Tables[0].ShowFirstColumn | should be $true
|
||||
$ws1.Tables[0].ShowLastColumn | should not be $true
|
||||
$ws1.Tables[0].ShowTotal | should be $true
|
||||
$ws1.Tables[0].Columns["Total"].TotalsRowFunction | Should be "Sum"
|
||||
$ws1.Tables[0].StyleName | should be "TableStyleLight1"
|
||||
$ws1.Cells["D4"].Style.Numberformat.Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
$ws1.Cells["E5"].Style.Numberformat.Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
$ws1.Tables[0].Address.Address | Should -Be "A1:E16"
|
||||
$ws1.Tables[0].Name | Should -Be "HardwareTable"
|
||||
$ws1.Tables[0].ShowFirstColumn | Should -Be $true
|
||||
$ws1.Tables[0].ShowLastColumn | Should -Not -Be $true
|
||||
$ws1.Tables[0].ShowTotal | Should -Be $true
|
||||
$ws1.Tables[0].Columns["Total"].TotalsRowFunction | Should -Be "Sum"
|
||||
$ws1.Tables[0].StyleName | Should -Be "TableStyleLight1"
|
||||
$ws1.Cells["D4"].Style.Numberformat.Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
$ws1.Cells["E5"].Style.Numberformat.Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
}
|
||||
it "Set the Pivot Options " {
|
||||
$ws2.PivotTables[0].DataFields[0].Format | Should match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
$ws2.PivotTables[0].ColumGrandTotals | Should be $false
|
||||
$ws2.PivotTables[0].StyleName | Should be "PivotStyleDark2"
|
||||
$ws2.PivotTables[0].DataFields[0].Format | Should -Match ([regex]::Escape([cultureinfo]::CurrentCulture.NumberFormat.CurrencySymbol))
|
||||
$ws2.PivotTables[0].ColumGrandTotals | Should -Be $false
|
||||
$ws2.PivotTables[0].StyleName | Should -Be "PivotStyleDark2"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,30 +28,30 @@ Describe "Data validation and protection" {
|
||||
$ws = $excelPackage.Sales
|
||||
}
|
||||
It "Created the expected number of rules " {
|
||||
$ws.DataValidations.count | Should be 2
|
||||
$ws.DataValidations.count | Should -Be 2
|
||||
}
|
||||
It "Created a List validation rule against a range of Cells " {
|
||||
$ws.DataValidations[0].ValidationType.Type.tostring() | Should be 'List'
|
||||
$ws.DataValidations[0].Formula.ExcelFormula | Should be 'values!$a$1:$a$10'
|
||||
$ws.DataValidations[0].Formula2 | Should benullorempty
|
||||
$ws.DataValidations[0].ValidationType.Type.tostring() | Should -Be 'List'
|
||||
$ws.DataValidations[0].Formula.ExcelFormula | Should -Be 'values!$a$1:$a$10'
|
||||
$ws.DataValidations[0].Formula2 | Should -Benullorempty
|
||||
}
|
||||
It "Created an integer validation rule for values between X and Y " {
|
||||
$ws.DataValidations[1].ValidationType.Type.tostring() | Should be 'Whole'
|
||||
$ws.DataValidations[1].Formula.Value | Should be 0
|
||||
$ws.DataValidations[1].Formula2.value | Should not benullorempty
|
||||
$ws.DataValidations[1].Operator.tostring() | should be 'between'
|
||||
$ws.DataValidations[1].ValidationType.Type.tostring() | Should -Be 'Whole'
|
||||
$ws.DataValidations[1].Formula.Value | Should -Be 0
|
||||
$ws.DataValidations[1].Formula2.value | Should -Not -Benullorempty
|
||||
$ws.DataValidations[1].Operator.tostring() | Should -Be 'between'
|
||||
}
|
||||
It "Set Error behaviors for both rules " {
|
||||
$ws.DataValidations[0].ErrorStyle.tostring() | Should be 'stop'
|
||||
$ws.DataValidations[1].ErrorStyle.tostring() | Should be 'stop'
|
||||
$ws.DataValidations[0].AllowBlank | Should be $true
|
||||
$ws.DataValidations[1].AllowBlank | Should be $true
|
||||
$ws.DataValidations[0].ShowErrorMessage | Should be $true
|
||||
$ws.DataValidations[1].ShowErrorMessage | Should be $true
|
||||
$ws.DataValidations[0].ErrorTitle | Should not benullorempty
|
||||
$ws.DataValidations[1].ErrorTitle | Should not benullorempty
|
||||
$ws.DataValidations[0].Error | Should not benullorempty
|
||||
$ws.DataValidations[1].Error | Should not benullorempty
|
||||
$ws.DataValidations[0].ErrorStyle.tostring() | Should -Be 'stop'
|
||||
$ws.DataValidations[1].ErrorStyle.tostring() | Should -Be 'stop'
|
||||
$ws.DataValidations[0].AllowBlank | Should -Be $true
|
||||
$ws.DataValidations[1].AllowBlank | Should -Be $true
|
||||
$ws.DataValidations[0].ShowErrorMessage | Should -Be $true
|
||||
$ws.DataValidations[1].ShowErrorMessage | Should -Be $true
|
||||
$ws.DataValidations[0].ErrorTitle | Should -Not -Benullorempty
|
||||
$ws.DataValidations[1].ErrorTitle | Should -Not -Benullorempty
|
||||
$ws.DataValidations[0].Error | Should -Not -Benullorempty
|
||||
$ws.DataValidations[1].Error | Should -Not -Benullorempty
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user