Fixed 'DataOnly' header issue

This has been fixed: Looks like it adds the "headers" in the sheet to
the data when you specify -DataOnly
This commit is contained in:
DarkLite1
2017-02-14 09:38:08 +01:00
parent 7cdf40e0c8
commit e68a5f27e5

View File

@@ -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 |