-
Notifications
You must be signed in to change notification settings - Fork 403
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
Odd behaviour on the return of Import-Excel function #792
Comments
@jhoneill I thought we had resolve this? Maybe something similar? |
Importing a one row sheet doesn't have a properly defined result. What it's doing at the moment certainly looks wrong. Commands don't return Generally you can do |
@DykVanDyke Yeah, this is a bug, need to figure out to remedy it. Optimally without introducing breaking changes. |
@DykVanDyke The fix is ready. If there are no rows, it issues a warning, and a You can grab the update module here and try it out before it is pushed to the gallery: |
Hello,
When we import an Excel file containing only 1 row of headers or 1 row of headers and 1 row of data, the function Import-Excel behaves in an odd manner, making the task of controling the size of the imported array of data a bit difficult.
With the attached file test.xlsx, you can test yourself the 2 cases for which the return of the function is a bit odd:
testing scenario 1: sheet 'no data'
$rows = Import-Excel -Path .\test.xlsx -WorksheetName 'no data'
In this case, the return of the function is an Object[] with 2 rows! The 1st is empty and the 2nd contains the headers.
testing scenario 2: sheet '1 row'
$rows = Import-Excel -Path .\test.xlsx -WorksheetName '1 row'
In this case, the return of the function is PSCustomObject.
For sheets with 2 or more rows, we get again returned objects of type Object[], which is the expected behaviour.
My questions/requests:
Couldn't we have the function returning always the type Object[] even for scenario 2?
In scenario 1, couldn't we have the function returning simply an empty object[] for which we simply would test the property count in order to check the empty contents?
test.xlsx
The text was updated successfully, but these errors were encountered: