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

Is it possible to get variable and where-object functions to work in import-excel? #1256

Closed
evolutionxtinct opened this issue Sep 23, 2022 Discussed in #1255 · 17 comments
Closed

Comments

@evolutionxtinct
Copy link

Discussed in #1255

Originally posted by evolutionxtinct September 23, 2022
Hello, i'm trying to utilize the -WorksheetName parameter, and it doesn't seem to like utilizing a $variable and it doesn't allow me to utilize where-object to search for a name in a tab.

I use this functionality for terminations and things like that, but they utilize a excel file per year, but the tabs stay the same, sadly they put it in this format: "Year Term" so I can't just look for worksheetname "Term" I have to look for something that contains the word "Term" in the parameter. Is it possible to get this worked in as it would be huge for us, thanks!

It comes up w/ the following error:

Import-Excel does not support reading this extension type
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.8.1\Public\Import-Excel.ps1:111 char:21
throw "Import-Excel does not support reading this extensi ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : OperationStopped: (Import-Excel do...extension type :String) [], RuntimeException
FullyQualifiedErrorId : Import-Excel does not support reading this extension type

@dfinke
Copy link
Owner

dfinke commented Sep 23, 2022

Please post the script/one liner that shows this

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 23, 2022 via email

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 23, 2022 via email

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 23, 2022 via email

@dfinke
Copy link
Owner

dfinke commented Sep 24, 2022

Need to see some data in the Excel file for context

@dfinke
Copy link
Owner

dfinke commented Sep 27, 2022

ok, I think I understand better. Import-Excel "$USER_LIST" defaults to reading the first worksheet in the xlsx, it doesn't read all of them. The Import-Excel doesn't return the worksheet name.

$xlfile = '.\test.xlsx'
Get-ExcelFileSummary $xlfile | Where-Object {
    $_.WorksheetName -match 'Sheet'
} | ForEach-Object {
    Import-Excel -path $xlfile -WorksheetName $_.WorksheetName 
}

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@dfinke
Copy link
Owner

dfinke commented Sep 27, 2022

Right, that's why you want to use Get-ExcelFileSummary, and pass the worksheets to process from there.

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@dfinke
Copy link
Owner

dfinke commented Sep 27, 2022

Those are all in the ImportExcel module

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Sep 27, 2022 via email

@dfinke
Copy link
Owner

dfinke commented Sep 27, 2022

Great. How did you create the $ExcelFileSummary?

@evolutionxtinct
Copy link
Author

evolutionxtinct commented Oct 11, 2022 via email

@dfinke
Copy link
Owner

dfinke commented Oct 11, 2022

No problem

@dfinke dfinke closed this as completed Oct 11, 2022
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

No branches or pull requests

2 participants