Giter Site home page Giter Site logo

dimakol / react-import-export-excel Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 2.56 MB

Import and export to excel file from table

Home Page: https://dimakol.github.io/react-import-export-excel/

License: MIT License

HTML 12.79% CSS 4.61% JavaScript 82.60%
reactjs xlsx

react-import-export-excel's Introduction

react-import-export-excel

This is an example project for importing/exporting data from/to excel file with following extensions: xlsx, csv from/to table in react using the following package: xlsx.

Motivation

The motivation behind this project was to implement ReactJS web application that allows import and export data between excel file and table that displayed in UI.

Screenshots

image

animated gif

Tech/framework used

Built with

Features

  • Export data from table to file: csv, xlsx.
  • Import data from file (csv, xlsx, xls) to table.

Code Examples

import * as XLSX from "xlsx";

const exportToExcel = (data, fileName, fileType) => {
    const workSheet = XLSX.utils.aoa_to_sheet(data);
    const workBook = { Sheets: { data: workSheet }, SheetNames: ["data"] };
    // Download
    XLSX.writeFile(workBook, fileName + "." + fileType);
  };

const importFromExcel = (file) => {
    const fileReader = new FileReader();
    fileReader.readAsArrayBuffer(file);

    fileReader.onload = (event) => {
      // parse data
      const bufferArray = event.target.result;
      const workBook = XLSX.read(bufferArray, { type: "array" });

      // get first sheet
      const workSheetName = workBook.SheetNames[0];
      const workSheet = workBook.Sheets[workSheetName];
      // convert to array
      const data = XLSX.utils.sheet_to_json(workSheet, { header: 1 });
      setFileName(getFileName(file));
      setTableData(data);
    };
  };

Installation

Running in development environment

git, npm and node softwares should be installed
before moving on

Package used

  • xlsx
  • react-bootstrap

Link to the website that hosting our project

https://dimakol.github.io/react-import-export-excel/

Credits

License

MIT © Dima Kolyas

react-import-export-excel's People

Contributors

dimakol avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.