-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix import excel headers #713
Conversation
I think this is by design - not that the design was right Basically we have two choices. "There are no headers" and "Replace the headers with ...". |
If you already digging in this subject can you see if you can implement the features I suggested in #579 I was thinking maybe doing something like this to address this problem + #579 + more option we will want to add now or later: # This is an incomplete mockup
# SYNTAX: New-HeaderDefinition [-MyTableHasHeaders] [-IncludeUndefinedHeaders]
$Headers = New-HeaderDefinition -MyTableHasHeaders
# SYNTAX set OriginalIndex : Add-HeaderDefinitionColumn -OriginalIndex <int> -NewName <string> [-NewIndex <int>]
# SYNTAX set OriginalName : Add-HeaderDefinitionColumn -OriginalName <string> -NewName <string> [-NewIndex <int>]
$Headers | Add-HeaderDefinitionColumn -OriginalIndex 1 -NewName 'New Name'
$Headers | Add-HeaderDefinitionColumn -OriginalName 'C3' -NewName 'Was C3' -NewIndex 1
Import-Excel -Headers $Headers
<#
Will replace
| C1 | C2 | C3 |
| A | B | C |
with
| Was C3 | New Name |
| C | A |
#> This way we can keep the number of parameters on Import-Excel to the minimum while giving more flexibility, but it requires more then one line of code to use. |
I'm all for doing the simplest change to get the desired outcome of the initial bug report, with an eye towards no breaking changes. Does the code change in the PR satisfy that? |
I think the simplest way is to change this bit at line 345 in importexcel.psm1
Put if($headerName) first and then elseif ($Noheader). That will set the names then it can either be run with startrow 2 (or top of data +1 ) or with -NoHeader (which means simplifying the parameter sets. Update help & tests, and job done. I |
Doing it KISS. @jhoneill Looks like the Any thoughts on the tests etc.? I didn't touch the parameter sets. I think the help looks good. |
No description provided.