A react library to render and display excel sheets on webpage
npm install react-excel-renderer
npm install react-excel-renderer --save
`
Usage
Import the primary module ExcelRenderer* to convert sheet data into JSON format.
Also import OutTable* to display the obtained JSON into a HTML Table.
`
import {OutTable, ExcelRenderer} from 'react-excel-renderer';
`
* Place a simple input element in the render function of your class and pass an onChange handler
`
`
* In the onChange handler, invoke the ExcelRenderer function and provide file object from the event handler to the ExcelRenderer function to obtain JSON data from sheet
`
fileHandler = (event) => {
let fileObj = event.target.files[0];
//just pass the fileObj as parameter
ExcelRenderer(fileObj, (err, resp) => {
if(err){
console.log(err);
}
else{
this.setState({
cols: resp.cols,
rows: resp.rows
});
}
});
}
`
* Use the OutTable component to render obtained JSON data into HTML table, and provide classnames as props to make table look alike an Excel Sheet
`
``