1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
var xlsx = require("node-xlsx").default;
var fs = require("fs");
const workSheetFromBuffer = xlsx.parse(fs.readFileSync(`${__dirname}/device.xlsx`));
console.log(JSON.stringify(workSheetFromBuffer));
var sheets_buf = [{"name":"Sheet1","data":[["第一行标题"],["序号","资产编码","设备名称"],[1,"ZCBM001","电脑"]]}];
sheets_buf.push({"name": "Sheet2", "data": [["第一行"], ["姓名", "年龄", "资产"], ["vhjx", "25", "负翁"], ["lx", "20", "jz"]]});
var xlsx_buf = xlsx.build(sheets_buf);
fs.writeFileSync("out.xlsx", xlsx_buf, {"encoding":"binary", "falg":"w"}); console.log("generate out.xlsx completed!");
|