mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Rename switch NotAsDictionary to Raw
This commit is contained in:
@@ -2,6 +2,6 @@ Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
|
|||||||
|
|
||||||
$xlfile = "$PSScriptRoot\yearlySales.xlsx"
|
$xlfile = "$PSScriptRoot\yearlySales.xlsx"
|
||||||
|
|
||||||
$result = Import-Excel -Path $xlfile -WorksheetName * -NotAsDictionary
|
$result = Import-Excel -Path $xlfile -WorksheetName * -Raw
|
||||||
|
|
||||||
$result | Measure-Object
|
$result | Measure-Object
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[String]$Password,
|
[String]$Password,
|
||||||
[Int[]]$ImportColumns,
|
[Int[]]$ImportColumns,
|
||||||
[Switch]$NotAsDictionary
|
[Switch]$Raw
|
||||||
)
|
)
|
||||||
end {
|
end {
|
||||||
$sw = [System.Diagnostics.Stopwatch]::StartNew()
|
$sw = [System.Diagnostics.Stopwatch]::StartNew()
|
||||||
@@ -239,7 +239,7 @@
|
|||||||
# $EndColumn = 0
|
# $EndColumn = 0
|
||||||
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
|
if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
|
||||||
|
|
||||||
if ($NotAsDictionary) {
|
if ($Raw) {
|
||||||
foreach ($entry in $xlbook.GetEnumerator()) {
|
foreach ($entry in $xlbook.GetEnumerator()) {
|
||||||
$entry.Value
|
$entry.Value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ Describe 'Different ways to import sheets' -Tag ImportExcelReadSheets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It 'Should return an array not a dictionary' {
|
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
|
$actual.Count | Should -Be 200
|
||||||
$group = $actual | Group-Object month -NoElement
|
$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["2015"].Count | Should -Be 12
|
||||||
$actual["2016"].Count | Should -Be 1
|
$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
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user