json-to-excel
Version:
json to excel for download
24 lines (18 loc) • 677 B
Markdown
fork from [rikkertkoppes/json2xls](https://github.com/rikkertkoppes/json2xls)
- cols add width property
- delete express middleware cause i use [koajs](http://koajs.com)
Download the json data as excel file.
```
var router = require('koa-router')();
router.get('/download', function* (){
var xls = json2xls(results);
this.type = 'application/vnd.openxmlformats';
this.set('Content-Type', 'application/vnd.openxmlformats');
this.set("Content-Disposition", "attachment; filename= download-json-to-excel.xlsx");
var buffer = new Buffer(xls,'binary');
this.body = buffer;
});
```