The ReactJS demo for js-xlsx is very unclear to me
See original GitHub issueSorry if I am not skilled enough to understand the demo, but this page: https://github.com/SheetJS/js-xlsx/tree/master/demos/react is very unclear to me and I still don’t get how this library has to be used in ReactJS.
How do we have to use this object
{
cols: [{ name: "A", key: 0 }, { name: "B", key: 1 }, { name: "C", key: 2 }],
data: [
[ "id", "name", "value" ],
[ 1, "sheetjs", 7262 ],
[ 2, "js-xlsx", 6969 ]
]
}
and download it as a xlsx? Please help!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
2 Answers - 2 - Stack Overflow
The cell object has the property f , which is the formula you want to use. Here you can see all the options: ......
Read more >React JS - React Tutorial for Beginners - YouTube
React JS Tutorial - Get up & running with React JS: the most popular JavaScript library in the world! - Want to master...
Read more >React JS— The Confusing Parts - Level Up Coding
What's so confusing about React? There are many reasons why certain parts of React may be confusing to a developer.
Read more >Tutorial: Intro to React
Overview will teach you the fundamentals of React: components, props, and state. Completing the Game will teach you the most common techniques in...
Read more >React Tutorial: An Overview and Walkthrough - Tania Rascia
Build a very simple React app that demonstrates the above concepts. Here's the source and a live demo of the end result.
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 FreeTop 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
Top GitHub Comments
If the demo doesn’t make sense, we probably are missing something. Here’s a longer explanation. If this makes sense, please let us know how to improve the README:
To run the demo, clone the repo and go to that subdirectory (
/demos/react
) and runmake && make react
, then go to http://localhost:8000 to see the demo.You should see something like:
Then select a spreadsheet by clicking the file input button or dragging and dropping a file like Book1.xlsx – you can click and download it.
If you add the line
console.log(this.state);
at the top of theexportFile
function, you can see the state when the file is generated:That object represents the state that the example uses. https://github.com/SheetJS/js-xlsx/blob/master/demos/react/sheetjs.jsx is the demo component used in the web examples.
this.state.data
is an array of arrays, so theexportFile
function just converts that part of the state:The callback is triggered when a certain button is clicked:
On the read side, the state is set when you process a file.
If that explanation makes sense, please feel free to submit a PR to clarify the README.
react ant design you can try to see https://github.com/dave-wind/excel