mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-10 21:33:16 +00:00
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:
@@ -99,7 +99,7 @@ function Import-Excel {
|
|||||||
$Rows=$dimension.Rows
|
$Rows=$dimension.Rows
|
||||||
$Columns=$dimension.Columns
|
$Columns=$dimension.Columns
|
||||||
|
|
||||||
if($NoHeader) {
|
if ($NoHeader) {
|
||||||
if ($DataOnly) {
|
if ($DataOnly) {
|
||||||
$CellsWithValues = $worksheet.Cells | where Value
|
$CellsWithValues = $worksheet.Cells | where Value
|
||||||
|
|
||||||
@@ -128,19 +128,20 @@ function Import-Excel {
|
|||||||
[PSCustomObject]$newRow
|
[PSCustomObject]$newRow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if(!$Header) {
|
else {
|
||||||
|
if (!$Header) {
|
||||||
$Header = foreach ($Column in 1..$Columns) {
|
$Header = foreach ($Column in 1..$Columns) {
|
||||||
$worksheet.Cells[$HeaderRow,$Column].Value
|
$worksheet.Cells[$HeaderRow,$Column].Value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($Rows -eq 1) {
|
if ($Rows -eq 1) {
|
||||||
$Header | ForEach {$h=[Ordered]@{}} {$h.$_=''} {[PSCustomObject]$h}
|
$Header | ForEach {$h=[Ordered]@{}} {$h.$_=''} {[PSCustomObject]$h}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($DataOnly) {
|
if ($DataOnly) {
|
||||||
$CellsWithValues = $worksheet.Cells | where Value
|
$CellsWithValues = $worksheet.Cells | where {$_.Value -and ($_.End.Row -ne 1)}
|
||||||
|
|
||||||
$Script:i = -1
|
$Script:i = -1
|
||||||
$ColumnReference = $CellsWithValues | Select-Object -ExpandProperty End | Group-Object Column |
|
$ColumnReference = $CellsWithValues | Select-Object -ExpandProperty End | Group-Object Column |
|
||||||
|
|||||||
Reference in New Issue
Block a user