Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

read_xlsx

0.0.4 • Public • Published

Read Excel API

npm install read_xlsx
var fs = require("fs");
var read_xlsx = require("../read_xlsx");
 
var excelBuffer = fs.readFileSync("./test.xlsx");
 
read_xlsx.getWorkbook(excelBuffer).then(function(workbook){
    var sheetNames = workbook.getSheetNames();
    console.log(sheetNames);
    
    workbook.getSheet("Sheet1").then(function(sheet){
        var rowLen = sheet.getRows();
        var cellLen = sheet.getColumns();
        for(var i=0; i<rowLen; i++) {
            for(var k=0; k<cellLen; k++) {
                var cell = sheet.getCell(i,k);
                //If the cell is empty, it is possible that the cell does not exist return null!
                if(cell !== null) {
                    console.log(cell.getName()+":"+cell.getContents())
                }
            }
        }
        
        //find cell by name
        var a1Sheet = sheet.findCell("A1");
        var a1Str = a1Sheet.getContents();
        console.log(a1Str)
    })["catch"](function(err) {
        console.error(err.stack);
    });
});

Install

npm i read_xlsx

DownloadsWeekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • avatar