我得到'res.xls不是一个函数,我已经安装了所有必需的软件包,但无法解析。我想将json数组转换为xls文件。
我在MySql中使用node.js。
const express = require('express');
const router = module.exports = express.Router();
const json2xls = require('json2xls');
router.use(json2xls.middleware);
function convert (req, res) {
var contacts = [{
name: 'Bob',
lastName: 'Smith'
}, {
name: 'James',
lastname: 'David'
}];
res.xls('report.xlsx', contacts);
}
我希望JSON数据应转换为xls文件。
app.get('/',function(req, res) {
var contacts = [{
name: 'Bob',
lastName: 'Smith'
}, {
name: 'James',
lastname: 'David'
}];
res.xls('report.xlsx', contacts);
});