Change the order of HeaderName and NoHeader. Adding tests.

This commit is contained in:
dfinke
2019-11-08 16:07:14 -05:00
parent 076a494523
commit ef6defd75c
2 changed files with 138 additions and 11 deletions

View File

@@ -342,20 +342,21 @@ function Import-Excel {
)
Try {
if ($NoHeader) {
$i = 0
foreach ($C in $Columns) {
$i++
$C | Select-Object @{N = 'Column'; E = { $_ } }, @{N = 'Value'; E = { 'P' + $i } }
}
}
elseif ($HeaderName) {
if ($HeaderName) {
$i = 0
foreach ($H in $HeaderName) {
$H | Select-Object @{N = 'Column'; E = { $Columns[$i] } }, @{N = 'Value'; E = { $H } }
$i++
}
}
elseif ($NoHeader) {
$i = 0
foreach ($C in $Columns) {
$i++
$C | Select-Object @{N = 'Column'; E = { $_ } }, @{N = 'Value'; E = { 'P' + $i } }
}
}
else {
if ($StartRow -lt 1) {
throw 'The top row can never be less than 1 when we need to retrieve headers from the worksheet.' ; return