output-controller.js
942 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
const Context = require('../common/context');
const nodeExcel = require('excel-export');
// 暂时弃用
class OutputController extends Context {
constructor() {
super();
}
productList(req, res, next) {
let conf = {
name: 'mysheet',
cols: [
{
caption: '列1',
type: 'string'
},
{
caption: '列2',
type: 'string'
}
],
rows: [
['1', '2'],
['3', '2'],
['4', '2']
]
};
let 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;