mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-13 06:43:17 +00:00
Added HeaderRow #47
This commit is contained in:
@@ -10,6 +10,7 @@ function Import-Excel {
|
|||||||
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory)]
|
[Parameter(ValueFromPipelineByPropertyName=$true, ValueFromPipeline=$true, Mandatory)]
|
||||||
$Path,
|
$Path,
|
||||||
$Sheet=1,
|
$Sheet=1,
|
||||||
|
[int]$HeaderRow=1,
|
||||||
[string[]]$Header,
|
[string[]]$Header,
|
||||||
[switch]$NoHeader
|
[switch]$NoHeader
|
||||||
)
|
)
|
||||||
@@ -43,11 +44,11 @@ function Import-Excel {
|
|||||||
} else {
|
} else {
|
||||||
if(!$Header) {
|
if(!$Header) {
|
||||||
$Header = foreach ($Column in 1..$Columns) {
|
$Header = foreach ($Column in 1..$Columns) {
|
||||||
$worksheet.Cells[1,$Column].Text
|
$worksheet.Cells[$HeaderRow,$Column].Text
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($Row in 2..$Rows) {
|
foreach ($Row in ($HeaderRow+1)..$Rows) {
|
||||||
$h=[Ordered]@{}
|
$h=[Ordered]@{}
|
||||||
foreach ($Column in 0..($Columns-1)) {
|
foreach ($Column in 0..($Columns-1)) {
|
||||||
if($Header[$Column].Length -gt 0) {
|
if($Header[$Column].Length -gt 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user