Reputation: 572
How to create/ add a new sheet file in an already existing xlsx file using the xlsx package by sheetjs in Node js?
This is my code by far, for an existing "todo-list.xlsx" file.
const xlsx = require('xlsx');
workBook = xlsx.readFile("todo-list.xlsx", {cellDates:true});
I would like to do something like this (this is done by using the Excel JS package):
const sheet = workbookStream.addSheet('sheet1');
... but using the xlsx package.
Thank you very much in advanced!
Upvotes: 3
Views: 12420
Reputation: 22758
There is an example of adding a new worksheet to an existing workbook In the official documentation:
var ws_name = "SheetJS";
/* make worksheet */
var ws_data = [
[ "S", "h", "e", "e", "t", "J", "S" ],
[ 1 , 2 , 3 , 4 , 5 ]
];
var ws = XLSX.utils.aoa_to_sheet(ws_data);
/* Add the worksheet to the workbook */
XLSX.utils.book_append_sheet(wb, ws, ws_name);
Upvotes: 8