Git Product home page Git Product logo

excel-class's Introduction

excel-class

npm npm Travis

a module helping to handle excel based on js-xlsx

中文文档

Getting start

npm install excel-class

APIs

Get the excel object and start to use it

const Excel = require('excel-class');
const path = require('path');
let excel = new Excel(path.join(__dirname,'test.xlsx')

tip: the path of the excel file should be absolute path

readSheet(sheet)

the argument can be type of Number or String

Read sheet by sheetName or sheetNumber, it will return json includes all data in the sheet.

excel.readSheet('Sheet1');
excel.readSheet(0);

readRow(sheet,rowNumber)

read the excel by rowNumber, the rowNumber should must largger than 0, if rowNumber is 0, this api will return an array contains headers.

readCell(sheet,rowNumber,cell)

return the correct cell of data, the cell can be type of Number or String.

excel.readCell('Sheet1',1,5);
excel.readCell('Sheet1',1,'name')

writeSheet(sheet,headers,data)

write a new sheet to the excel, if the sheet has exsited, the new data will replace it. And the other sheets in the excel will not changed.

headers shoud be an array contains the headers of this sheet, and data should be type of array and it contains data of rows. This api will return a promise.

excel.writeSheet('Sheet1',['name','age','country'],[
    {
        name: 'Jane',
        age: 19,
        country: 'China'
    },
    {
        name: 'Maria',
        age: 20,
        country: 'America'
    }
]).then(()=>{
    //do other things
});

writeRow(sheet,row,data)

write the data of row in the sheet, the data should be a object, this api will return a promise

excel.writeRow('Sheet1',1,{
    name: 'Jane',
    age: 19,
    country: 'China'
}).then(()=>{
    //do other things
})

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.