Compare commits

..

4 Commits

Author SHA1 Message Date
dfinke
79e5bdf8ba update 2022-05-03 17:54:21 -04:00
dfinke
b03d9b048a bump version 2022-05-03 17:54:16 -04:00
dfinke
aea90aa8d6 Fix reading multiple sheets in the xlsx where row/col count is diff 2022-05-03 17:53:58 -04:00
dfinke
d4ebc9e95d Use explicit parameter names 2022-04-30 13:17:20 -04:00
7 changed files with 19 additions and 5 deletions

View File

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

View File

@@ -2,7 +2,7 @@ Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 -Force
$xlfile = "$PSScriptRoot\yearlySales.xlsx" $xlfile = "$PSScriptRoot\yearlySales.xlsx"
$result = Import-Excel $xlfile * $result = Import-Excel -Path $xlfile -WorksheetName *
foreach ($sheet in $result.Values) { foreach ($sheet in $result.Values) {
$sheet $sheet

View File

@@ -6,7 +6,7 @@
RootModule = 'ImportExcel.psm1' RootModule = 'ImportExcel.psm1'
# Version number of this module. # Version number of this module.
ModuleVersion = '7.5.0' ModuleVersion = '7.5.1'
# ID used to uniquely identify this module # ID used to uniquely identify this module
GUID = '60dd4136-feff-401a-ba27-a84458c57ede' GUID = '60dd4136-feff-401a-ba27-a84458c57ede'

View File

@@ -134,6 +134,8 @@
$xlBook = [Ordered]@{} $xlBook = [Ordered]@{}
foreach ($sheet in $Worksheet) { foreach ($sheet in $Worksheet) {
$EndRow = 0
$EndColumn = 0
$targetSheetname = $sheet.Name $targetSheetname = $sheet.Name
$xlBook["$targetSheetname"] = @() $xlBook["$targetSheetname"] = @()
#region Get rows and columns #region Get rows and columns
@@ -233,8 +235,8 @@
} }
catch { throw "Failed importing the Excel workbook '$Path' with worksheet '$WorksheetName': $_"; return } catch { throw "Failed importing the Excel workbook '$Path' with worksheet '$WorksheetName': $_"; return }
finally { finally {
$EndRow = 0 # $EndRow = 0
$EndColumn = 0 # $EndColumn = 0
if ($Path) { $stream.close(); $ExcelPackage.Dispose() } if ($Path) { $stream.close(); $ExcelPackage.Dispose() }
if ($NotAsDictionary) { if ($NotAsDictionary) {

View File

@@ -59,5 +59,15 @@ Describe 'Different ways to import sheets' -Tag ImportExcelReadSheets {
$group[0].Name | Should -BeExactly 'April' $group[0].Name | Should -BeExactly 'April'
$group[1].Name | Should -BeExactly 'June' $group[1].Name | Should -BeExactly 'June'
} }
It "Should read multiple sheets with diff number of rows correctly" {
$xlFilename = "$PSScriptRoot\construction.xlsx"
$actual = Import-Excel $xlFilename 2015, 2016
$actual.keys.Count | Should -Be 2
$actual["2015"].Count | Should -Be 12
$actual["2016"].Count | Should -Be 1
}
} }
} }

Binary file not shown.

View File

@@ -1,3 +1,5 @@
# v7.5.1
- Fixed `Import-Excel` - Reset `EndRow` and `EndColumn` in the correct place.
# v7.5.0 # v7.5.0
## Fixes ## Fixes