Skip to content
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

Import-Excel Extended HeaderName functionality #579

Closed
wants to merge 1 commit into from

Conversation

ili101
Copy link
Contributor

@ili101 ili101 commented Apr 8, 2019

I was using Import-Excel on a file and found that I don't like the headers names and that I don't need them all, I tried to use -HeaderName but it was not doing exactly what I needed. First It depends on the headers position and not name, and also I can't skip columns I don't need.
So I added the option to send HashTable to it (In addition to the existing array option) with the columns you want to get and there new name, this lets you do 3 things:

  1. Select only the Columns you want (By name).
  2. Reorder them if you need.
  3. Rename them if you need.

Example of getting only (Process Name, Start, Path) https://github.com/ili101/ImportExcel/blob/Import-ExcelExtendedHeaderName/Examples/Import-ExcelWithHeaderName.ps1

I don't know if this is the best way to do it, or if the implementation is good, So what do you think? I will like to get your opinions.

@cprograemer84
Copy link

Hi, The last line of the code is not working for me
Import-Excel -Path $path -HeaderName ([Ordered]@{Name = 'Process Name' ; StartTime = 'Start'; Path = 'Path'})

Windows 10
Powershell 5.1.16299.1146
Import Excel :5.4.4

Output:

System.Collections.Specialized.OrderedDictionary

acwebbrowser
acwebbrowser
acwebbrowser
AdAppMgrSvc
ApplicationFrameHost
armsvc
audiodg

@ili101 ili101 force-pushed the Import-ExcelExtendedHeaderName branch from cbbf205 to 8e7a102 Compare June 16, 2019 12:50
@ili101
Copy link
Contributor Author

ili101 commented Jun 16, 2019

@cprograemer84 I think you are running my example code on the original version and not on the version from my PR.
Get the version from https://github.com/ili101/ImportExcel/tree/Import-ExcelExtendedHeaderName (with git or just download from https://ci.appveyor.com/api/buildjobs/ryjtw4yqqwhoavjl/artifacts/ImportExcel-6.2.0-20190616125028.zip)
Then make sure it's loaded by running Import-Module [Path to extracted module version] -Force
Then run the example code (Update us if it works for you 👍)

@ili101 ili101 mentioned this pull request Nov 5, 2019
@dfinke dfinke closed this May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants