koa2-boilerplate-plus
Version:
Enhanced koa2 boilerplate
23 lines (17 loc) • 511 B
JavaScript
;
import Router from 'koa-router';
import NodeExcel from 'excel-export';
const router = new Router();
router.get('/export', async (ctx, next) => {
let conf = {}
conf.cols = [{
caption:'Header',
type:'string',
width: 145
}]
conf.rows = [['value01'], ['value02'], ['value03']]
ctx.type = 'application/vnd.openxmlformats'
ctx.attachment( "Report.xlsx")
ctx.body = new Buffer(NodeExcel.execute(conf), 'binary')
})
export default router;