![](/img/trans.png)
[英]How to create more than one XLSX sheet from HTML table in js-xlsx (sheetjs)?
[英]How to create a new sheet in an existing xlsx file using xlsx/sheetjs package in node js?
如何在 Node js 中使用 sheetjs 的xlsx package在已經存在的 xlsx 文件中創建/添加新的工作表文件?
到目前為止,這是我的代碼,用於現有的“todo-list.xlsx”文件。
const xlsx = require('xlsx');
workBook = xlsx.readFile("todo-list.xlsx", {cellDates:true});
我想做這樣的事情(這是通過使用 Excel JS 包完成的):
const sheet = workbookStream.addSheet('sheet1');
...但使用 xlsx package。
非常感謝您的先進!
官方文檔中有一個向現有工作簿添加新工作表的示例:
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);
請參閱使用工作簿
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.