Skip to content

Commit

Permalink
Rename switch NotAsDictionary to Raw
Browse files Browse the repository at this point in the history
  • Loading branch information
dfinke committed May 4, 2022
1 parent 0b3b382 commit 4fa34ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Examples/Import-Excel/ImportMultipleSheetsAsArray.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Public/Import-Excel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
[ValidateNotNullOrEmpty()]
[String]$Password,
[Int[]]$ImportColumns,
[Switch]$NotAsDictionary
[Switch]$Raw
)
end {
$sw = [System.Diagnostics.Stopwatch]::StartNew()
Expand Down Expand Up @@ -239,7 +239,7 @@
# $EndColumn = 0
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }

if ($NotAsDictionary) {
if ($Raw) {
foreach ($entry in $xlbook.GetEnumerator()) {
$entry.Value
}
Expand Down
11 changes: 10 additions & 1 deletion __tests__/ImportExcelTests/ImportExcelReadSheets.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

}
}

0 comments on commit 4fa34ae

Please sign in to comment.