Rename switch NotAsDictionary to Raw

This commit is contained in:
dfinke
2022-05-04 18:33:19 -04:00
parent 0b3b382c4e
commit 4fa34ae257
3 changed files with 13 additions and 4 deletions

View File

@@ -2,6 +2,6 @@ Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
$xlfile = "$PSScriptRoot\yearlySales.xlsx"
$result = Import-Excel -Path $xlfile -WorksheetName * -NotAsDictionary
$result = Import-Excel -Path $xlfile -WorksheetName * -Raw
$result | Measure-Object

View File

@@ -37,7 +37,7 @@
[ValidateNotNullOrEmpty()]
[String]$Password,
[Int[]]$ImportColumns,
[Switch]$NotAsDictionary
[Switch]$Raw
)
end {
$sw = [System.Diagnostics.Stopwatch]::StartNew()
@@ -239,7 +239,7 @@
# $EndColumn = 0
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
if ($NotAsDictionary) {
if ($Raw) {
foreach ($entry in $xlbook.GetEnumerator()) {
$entry.Value
}

View File

@@ -50,7 +50,7 @@ Describe 'Different ways to import sheets' -Tag ImportExcelReadSheets {
}
It 'Should return an array not a dictionary' {
$actual = Import-Excel $xlFilename april, june -NotAsDictionary
$actual = Import-Excel $xlFilename april, june -Raw
$actual.Count | Should -Be 200
$group = $actual | Group-Object month -NoElement
@@ -69,5 +69,14 @@ Describe 'Different ways to import sheets' -Tag ImportExcelReadSheets {
$actual["2015"].Count | Should -Be 12
$actual["2016"].Count | Should -Be 1
}
It "Should read multiple sheets with diff number of rows correctly and flatten it" {
$xlFilename = "$PSScriptRoot\construction.xlsx"
$actual = Import-Excel $xlFilename 2015, 2016 -Raw
$actual.Count | Should -Be 13
}
}
}