-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datatables 需要把表格数据导出成一个excel表格文件,包含多个worksheet #356
Comments
合并 #307 说明导出。。不要使用前端实现方式。。使用后端实现。
提供一个解决思路前端
后端
几点说明:1、 一定、不要在前端完成全量数据的拼接,数据拉取过程中极有可能 |
同样,你这个问题。。后端用 如果是 |
Closed
This was referenced Oct 26, 2018
Closed
大体的示例代码,可有效解决 const stringify = require('csv-stringify/lib/sync');
const { Iconv } = require('iconv');
// data 为原始数据
// columns 为excel的自定义头部,具体见csv中header和columns的说明
const json = await stringify(data, { header: true, columns });
const iconv = new Iconv('UTF-8', 'GBK//IGNORE'); // 定义buffer的转码器
const content = iconv.convert(json);
const filename = iconv.convert('中文文件名.csv').toString('binary');
res.setHeader('Pragma', 'public');
res.setHeader('Expires', '0');
res.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0');
res.setHeader('Content-Type', 'text/csv; charset=GBK');
res.setHeader('Content-Disposition', 'attachment;filename="' + filename + '"');
res.setHeader('Content-Length', content.length);
res.end(content); |
Closed
This was referenced Dec 3, 2018
Closed
Closed
Closed
Closed
Open
Closed
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使用 datatables 把数据展示成表格已经OK。
使用 excel buttons 也实现了把表格导出成 excel 文件。
但是默认导出的 excel 只有一个 sheet
现在需要把表格数据导出成一个excel表格文件,包含多个sheet,如何实现?
The text was updated successfully, but these errors were encountered: