项目作者: NoobTW

项目描述 :
Json to excel(xlsx) middleware for koa.
高级语言: JavaScript
项目地址: git://github.com/NoobTW/koa-json2xlsx.git
创建时间: 2018-02-18T11:24:37Z
项目社区:https://github.com/NoobTW/koa-json2xlsx

开源协议:MIT License

下载


koa-json2xlsx

Build status Node version

Json to excel(xlsx) middleware for koa

Need async/await support, so you have to use Node v7.6+, or use --harmony option.

Installation

Install using npm:

  1. npm install koa-json2xlsx

Usage

  1. const Koa = require('koa');
  2. const koaJson2xlsx = require('koa-json2xlsx');
  3. const app = new Koa();
  4. const data = [
  5. {
  6. name: 'Peter',
  7. age: 18,
  8. foo: 'bar'
  9. },
  10. {
  11. name: 'Jane',
  12. age: 19,
  13. foo: 'bar'
  14. }
  15. ];
  16. app.use(koaJson2xlsx());
  17. app.use(ctx => {
  18. ctx.xlsx('data.xlsx', data);
  19. });

Reference

xlsx

ctx.xlsx(filename, [option])

You can find available option here.

xls

An alias of xlsx.

Tests

Run tests using npm test.