`json_to_sheet` mutates header array
See original GitHub issueWhile I try to change header titles by passing array of titles to options like below it does not override the headers. Instead it writes new headers first and original data with old headers again from next cell.
I am experiencing the same problem.
In addition, sheets js is mutating the header array passed in, which is not something I would ever expect.
Example:
const header = ['field2', 'field3'];
const data = [{field1: 'foo', 'field2': 'bar', 'field3': 'baz'}]
const worksheet = XLSX.utils.json_to_sheet(data, {header});
console.log(header); // RESULTS: ["field2", "field3", "field1"]
_Originally posted by @paustint in https://github.com/SheetJS/sheetjs/issues/1487#issuecomment-706759470_
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
while using header option with XLSX.utils.json_to_sheet ...
While I try to change header titles by passing array of titles to options like below it does not override the headers. Instead...
Read more >How to read and write Excel file in Node.js ? - GeeksforGeeks
We use two main functions in this program i.e json_to_sheet() which accepts an array of objects and converts them into a worksheet and ......
Read more >Data Grids and Tables | SheetJS Community Edition
The sheet_to_json utility function generates arrays of objects, which is suitable for a number of libraries. When more advanced shapes are ...
Read more >[Solved]-angular material data table export to excel-angular.js
In my case, alternative to table_to_sheet is to use json_to_sheet . Since I don't know how to properly export the table (with pagination)...
Read more >How to Import Export Excel & CSV In React 2022
json_to_sheet converts an array of JS objects to a worksheet ... Open the App.js file and make the following changes.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Now that you understand this, maybe you can help improve the docs 😃 We’ll accept a PR that clarifies the behavior.
af34ae4178390974977101221d9f48869d5a1228