The Wayback Machine - https://web.archive.org/web/20200831010818/https://github.com/SheetJS/sheetjs/issues/2077
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

Null worksheet when creating an empty worksheet with header using json_to_sheet #2077

Open
sporsherbaire opened this issue Aug 4, 2020 · 1 comment

Comments

@sporsherbaire
Copy link

@sporsherbaire sporsherbaire commented Aug 4, 2020

Since version 0.16.5, th following code returns a null worksheet:
XLSX.utils.json_to_sheet([], {header: columns})

Is it now working as it is wanted? If so, how could we create an empty worksheet? In my case it is expected that sometimes the data is an empty array. And an empty worksheet only with headers is expected.

@sporsherbaire sporsherbaire changed the title Null worksheet object when creating an empty worksheet with header using json_to_sheet Null worksheet when creating an empty worksheet with header using json_to_sheet Aug 4, 2020
@SheetJSDev
Copy link
Contributor

@SheetJSDev SheetJSDev commented Aug 4, 2020

XLSX.utils.aoa_to_sheet([columns]) should be the preferred approach in general.

That said, https://github.com/SheetJS/sheetjs/blob/master/bits/90_utils.js#L182 is the offending line and can be removed -- there was no intention to change the behavior in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.