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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…