From e68a5f27e57fcd7af2b96216a6e59238aa6a063f Mon Sep 17 00:00:00 2001 From: DarkLite1 Date: Tue, 14 Feb 2017 09:38:08 +0100 Subject: [PATCH] Fixed 'DataOnly' header issue This has been fixed: Looks like it adds the "headers" in the sheet to the data when you specify -DataOnly --- ImportExcel.psm1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ImportExcel.psm1 b/ImportExcel.psm1 index 1f0dce9..f173fa8 100644 --- a/ImportExcel.psm1 +++ b/ImportExcel.psm1 @@ -99,7 +99,7 @@ function Import-Excel { $Rows=$dimension.Rows $Columns=$dimension.Columns - if($NoHeader) { + if ($NoHeader) { if ($DataOnly) { $CellsWithValues = $worksheet.Cells | where Value @@ -128,19 +128,20 @@ function Import-Excel { [PSCustomObject]$newRow } } - } else { - if(!$Header) { + } + else { + if (!$Header) { $Header = foreach ($Column in 1..$Columns) { $worksheet.Cells[$HeaderRow,$Column].Value } } - if($Rows -eq 1) { + if ($Rows -eq 1) { $Header | ForEach {$h=[Ordered]@{}} {$h.$_=''} {[PSCustomObject]$h} } else { if ($DataOnly) { - $CellsWithValues = $worksheet.Cells | where Value + $CellsWithValues = $worksheet.Cells | where {$_.Value -and ($_.End.Row -ne 1)} $Script:i = -1 $ColumnReference = $CellsWithValues | Select-Object -ExpandProperty End | Group-Object Column |