nodejs导出excel

//导出Excel
var nodeExcel = require("excel-export");
var fs = require("fs");

var conf = {};
conf.cols = [{
    caption: '姓名',
    type: "string"
}, {
    caption: '年龄',
    type: "number"
}];
conf.rows = [
    ["张三", 25],
    ["张三", 28],
    ["李四", 24]
];

var result = nodeExcel.execute(conf);

fs.writeFile("aaa.xls", result, 'binary', function (err) {
    if (err) {
        console.log(err);
    } else {
        console.log("success");
    }
})

 

posted @ 2018-04-20 15:46  段江涛IT  阅读(236)  评论(0编辑  收藏  举报
页脚HTML代码