nodejs写excel

1、安装第三方库

npm install node-xlsx --save


2、实现代码:

var fs = require('fs');
var xlsx = require('node-xlsx');

var buffer = xlsx.build({worksheets: [
  {"name":"mySheetName", "data":[
    ["A1", "B1"],
    [
      {"value":"A2","formatCode":"General"},
      {"value":"B2","formatCode":"General"}
    ]
  ]}
]});
fs.writeFileSync("./myFile.xlsx, buffer, 'binary')


你可能感兴趣的:(Excel,nodejs)