Coder Social home page Coder Social logo

react-excel-renderer's Introduction

react-excel-renderer

A react library to render and display excel sheets on webpage


Demo

  • A sample demo can be found - here
  • You can find code for the demo - here

Installation

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
<input type="file" onChange={this.fileHandler.bind(this)} style={{"padding":"10px"}} />
  • 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
<OutTable data={this.state.rows} columns={this.state.cols} tableClassName="ExcelTable2007" tableHeaderRowClass="heading" />

Note: Once the JSON data is obatined, you can also use other options to render them instead of the OutTable component. For example, CanvasDataGrid provides various features to render tabular data.

Built With

  • SheetJS - The web page sheet framework used

Authors

Ashish Deshpande - Initial work - Ashish's Github Profile

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • Special shout out to the guys at Sheet JS for developing the parent library
  • High gratitude towards Bernard Bado to help me publish my first npm package

react-excel-renderer's People

Contributors

ashishd751 avatar unger1984 avatar coldshower avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.