output-controller.js
751 Bytes
const Context = require('../framework/context');
const nodeExcel = require('excel-export');
// 暂时弃用
class OutputController extends Context {
constructor() {
super();
}
productList(req, res) {
const conf = {
name: 'mysheet',
cols: [
{
caption: '列1',
type: 'string',
},
{
caption: '列2',
type: 'string',
},
],
rows: [['1', '2'], ['3', '2'], ['4', '2']],
};
const result = nodeExcel.execute(conf);
res.setHeader('Content-Type', 'application/vnd.openxmlformats');
res.setHeader('Content-Disposition', 'attachment; filename=productList.xlsx');
res.end(result, 'binary');
}
}
module.exports = OutputController;