2

Its time to ask it in StackOverflow, since I have found more than one excel libraries, some based in client side and some based in server side.

First

I am using Node.js, where is preferred to use Excel libraries, client or server side?

Second

Which is a good Excel library you know and trust? I have tried to install this: https://github.com/natergj/excel4node But unfortune it throws the next error in the CLI:

module.js:544
    throw err;
    ^

Error: Cannot find module 'excel4node'
    at Function.Module._resolveFilename (module.js:542:15)
    at Function.Module._load (module.js:472:25)
    at Module.require (module.js:585:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/razbuchnik/node/app.js:11:10)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)
    at Function.Module._load (module.js:495:3)
[nodemon] app crashed - waiting for file changes before starting...

Any good advice here?

Thanks.

Raz
  • 1,910
  • 1
  • 15
  • 28

2 Answers2

6

You can use npm install exceljs

var Excel = require('exceljs');
var workbook = new Excel.Workbook();

workbook.xlsx.readFile('old.xlsx')
    .then(function() {
        var worksheet = workbook.getWorksheet(1);
        var row = worksheet.getRow(5);
        row.getCell(1).value = 5; // A5's value set to 5
        row.commit();
        return workbook.xlsx.writeFile('new.xlsx');
    })

See more information here, in the package's page.

Or here, in other stackoverflow answer.

Hope this help.

Fernando Paz
  • 532
  • 6
  • 19
  • Yes, I have just found this, and it works very good. Thank you for support. – Raz Jan 19 '18 at 08:42
  • When write into new file missing richText, https://stackoverflow.com/questions/58135659/richtext-missing-in-exceljs-nodejs – Vineesh TP Sep 29 '19 at 18:58
2

You can't use require('excel4node') without install it, try npm install excel4node to install it