Modify existing Excel File using node.js
Is there any way to modify existing excel file in node.js? I've looked into exceljs but it does not provide any functionality that will just modify the existing data. It seems like it will write to a new stream.
Or did I miss something on exceljs?
Thanks in advance.
exceljs does let you modify Excel spreadsheets.
Here's an example of reading in an existing spreadsheet and writing it back out to a different file:
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');
})
If you're using the Streams API with exceljs
, you can also pipe your stream into fs.createWriteStream
to write to a file as well.
Please note that StackOverflow is not meant to be a platform for getting help in your search for a module.
Anyway, I'd suggest that you have a loo at xlsx. This module can read, parse, and write Excel files, and hence should do what you are looking for.
链接地址: http://www.djcxy.com/p/93582.html