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

When using empty arrays, Worksheets won't get added, resulting in a corrupt xlsx #48

Open
moonwitch opened this issue Feb 23, 2017 · 3 comments

Comments

@moonwitch
Copy link

moonwitch commented Feb 23, 2017

Index operation failed; the array index evaluated to null.
At C:\Program Files\WindowsPowerShell\Modules\PSExcel\1.0.2\Export-XLSX.ps1:477 char:17

  • ... $WorkSheet.Cells[$WorkSheet.Dimension.Address].AutoFitCol ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArrayIndex

Long story short, I have to create a report where I have a list of AD groups, the report follows the format AD Groupname as Sheetname, the groupmembers go into the sheets. Some groups are empty, and on those groups - this errors out.

@moonwitch
Copy link
Author

I would like to add: This is indeed caused by feeding $null into the width (-Autofit)
Not sure if this is a bug then, but if you use the switch and have empty values (PSObject), you will have a corrupt xlsx.

@RamblingCookieMonster
Copy link
Owner

Hi!

Good find, and thanks for the follow up detail, should make it easier to track down!

Feel free to poke around if you'd like, would be happy to take a PR - otherwise, will try to take a peek (might be a few weeks).

Cheers!

@RamblingCookieMonster
Copy link
Owner

Not published in the gallery, but put in a test to skip applying autofit if there's no data - guessing there might be other switches with similar behavior. Thanks for pointing out where and why this was failing!

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

2 participants