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

Cannot figure out what is causing "Cannot index into a null array" error #1633

Open
ImranMoTown opened this issue Sep 6, 2024 · 3 comments
Assignees

Comments

@ImranMoTown
Copy link

ImranMoTown commented Sep 6, 2024

Something in this workbook is raising this error:
Failed importing the Excel workbook 'C:\Data\CopiedData.xlsm' with worksheet 'Sheet1': Cannot index into a null array.

This workbook is a pared down version of a much larger workbook, I've deleted all other sheets, all other data, all vba code, everything except the header column row and the one row of data.

This is my call to ImportExcel:
$Data = Import-Excel -Path "C:\Data\CopiedData.xlsm" -ImportColumns 1,2 -WorksheetName "Sheet1" -DataOnly -StartRow 1 -AsText "*";

I've found that regardless of what I put in the WorksheetName param, I get the same result, even if I omit the WorksheetName param, I get the same result.

See attached zipped up .xlsm file
CopiedData.zip

Tried versions 7.8.6 and 7.8.9

Really appreciate any help anyone can provide.

@dfinke dfinke self-assigned this Sep 6, 2024
@dfinke
Copy link
Owner

dfinke commented Sep 6, 2024

I get the same error.

I created a new xlsm and added the same cell contents. I was able to read it no problem with the simple Import-Excel approach.

Seems like it is issue with your xlsm.

$xlfile = ".\CopiedData.xlsm"
Import-Excel $xlfile -WorksheetName 'Sheet1'

image

@ImranMoTown
Copy link
Author

Agreed, was hoping for some insight into what it was. This is one of several dozen large workbooks. Rebuilding them will be a huge task.

@dfinke
Copy link
Owner

dfinke commented Sep 7, 2024

Yes, understood, sorry. I have not be able to track those down, and have seen hardly any over the years.

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