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

Selecting Columns in ConvertFromExceltoSQLInsert.ps1 #595

Closed
TerryGriner opened this issue May 16, 2019 · 3 comments
Closed

Selecting Columns in ConvertFromExceltoSQLInsert.ps1 #595

TerryGriner opened this issue May 16, 2019 · 3 comments

Comments

@TerryGriner
Copy link

I like what the cmdlet does, I just would like a Parameter that would allow me to select specific Columns from the spreadsheet to import into SQL data table. To use the example to illustrate;
| File: Movies.xlsx - Sheet: Sheet1 |

| A B C |
|1 Movie Name Year Rating |
|2 The Bodyguard 1992 9 |
|3 The Matrix 1999 8 |
|4 Skyfall 2012 9 |
|5 The Avengers 2012 |

I want to be able to select column A and B, but not get C on the import.

@ili101
Copy link
Contributor

ili101 commented May 16, 2019

@dfinke It looks like the parameters on ConvertFrom-ExcelData and ConvertFrom-ExcelToSQLInsert are outdated.
This should do what @TerryGriner want:

ConvertFrom-ExcelToSQLInsert -Path Book1.xlsx -TableName Test -HeaderName 'A', 'B'

But on ConvertFrom-ExcelData and ConvertFrom-ExcelToSQLInsert the parameter name is -Header instead of -HeaderName like in Import-Excel so you get an error.

Maybe it will be best to set DynamicParam on ConvertFrom-ExcelData and ConvertFrom-ExcelToSQLInsert from Import-Excel like @jhoneill did in Send-SQLDataToExcel in the last update so it will be updated automatically.

@ili101
Copy link
Contributor

ili101 commented May 16, 2019

Also if you want 'A' and 'C' instead of 'A', 'B' you can't do it with -HeaderName but with something like what I proposed in here #579 you can select any column you want with -HeaderName

@dfinke
Copy link
Owner

dfinke commented May 16, 2019

Didn't think of using HeaderName, was looking at adding -Property and use Select-Object.

I'll take a look at #579 too.

@dfinke dfinke closed this as completed May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants