shoots-plugin-xlsx-export
用法
可用于router下或lambda下
lambda用法
function getData(worksheet, workbook, resp) {
return new Promise((res, rej) => {
setTimeout(() => {
res(null)
}, 10000)
})
}
let shootsExport = require('shoots-plugin-xlsx-export')
module.exports = async function (params, ctx, next) {
let ins = new shootsExport(ctx, {
fileName: '导出的文件名',
sheetName: "defaultsheet",
columns: [{
header: '标题',
key: 'Title',
width: 10
}, {
header: '标题1',
key: 'Title1',
width: 10
}, {
header: '标题2',
key: 'Title2',
width: 10
}]
})
ctx.succeed(ins.start())
let data = getData().then(() => {
ins.addRow({
Title1: 'Title1',
Title2: 'Title1',
Title: 'Title1'
})
ins.addRow({
Title1: 'Title1_line2',
Title2: 'Title1_line2',
Title: 'Title1_line2'
})
ins.build()
})
}