diff --git a/ImportExcel.psm1 b/ImportExcel.psm1 index f28b0b3..50d033c 100644 --- a/ImportExcel.psm1 +++ b/ImportExcel.psm1 @@ -80,15 +80,19 @@ function Import-Excel { } } - foreach ($Row in ($HeaderRow+1)..$Rows) { - $h=[Ordered]@{} - foreach ($Column in 0..($Columns-1)) { - if($Header[$Column].Length -gt 0) { - $Name = $Header[$Column] - $h.$Name = $worksheet.Cells[$Row,($Column+1)].Value + if($Rows -eq 1) { + $Header | ForEach {$h=[Ordered]@{}} {$h.$_=''} {[PSCustomObject]$h} + } else { + foreach ($Row in ($HeaderRow+1)..$Rows) { + $h=[Ordered]@{} + foreach ($Column in 0..($Columns-1)) { + if($Header[$Column].Length -gt 0) { + $Name = $Header[$Column] + $h.$Name = $worksheet.Cells[$Row,($Column+1)].Value + } } + [PSCustomObject]$h } - [PSCustomObject]$h } } diff --git a/README.md b/README.md index 2ef285f..436c84c 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,9 @@ iex (new-object System.Net.WebClient).DownloadString('https://raw.github.com/dfi # What's new +#### 7/21/2016 +* Fixes `Import-Excel` #68 + #### 7/7/2016 [Attila Mihalicz](https://github.com/attilamihalicz) fixed two issues