当前位置:网站首页>Export El table as is to excel table
Export El table as is to excel table
2022-06-30 21:19:00 【bidepanm】
Installation dependency
npm install --save xlsx file-saver
introduce
import XLSX from 'xlsx';
import FileSaver from 'file-saver';
Export method
exportExcel(excelName) {
//excelName -- Set the exported excel name
//report-table -- Corresponding to the... To be exported el-table Of ref name
try {
const $e = this.$refs['report-table'].$el;
// If the table is added fixed attribute , Then the exported file will produce two copies of the same data , So you can judge here
let $table = $e.querySelector('.el-table__fixed');
if (!$table) {
$table = $e;
}
// To return the cell's original string , Set up { raw: true }
const wb = XLSX.utils.table_to_book($table, { raw: true });
const wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' });
FileSaver.saveAs(
new Blob([wbout], { type: 'application/octet-stream' }),
`${excelName}.xlsx`,
);
} catch (e) {
if (typeof console !== 'undefined') console.error(e);
}
}
https://github.com/SheetJS/js-xlsx
https://github.com/eligrey/FileSaver.js
https://segmentfault.com/a/1190000022936812
边栏推荐
- 报错:Internal error XFS_WANT_CORRUPTED_GOTO at line 1635 of file fs/xfs/libxfs/xfs_alloc.c.
- Qiao NPMS: search for NPM packages
- ArcGIS construction and release of simple road network data service and rest call test
- Peking University ACM problems 1004:financial management
- Two skylines
- 毕业五年,想当初若没有入行测试,我是否还会如这般焦虑
- DM8:生成DM AWR报告
- 个人开发的渗透测试工具Satania
- [grade evaluator] how to register a grade evaluator? How many passes?
- MySQL advanced 3
猜你喜欢
随机推荐
的撒啊苏丹看老司机
asp.net core JWT传递
多态在代码中的体现
Icml2022 | utility theory of sequential decision making
What happens when word encounters an error while trying to open a file?
开发技术-获取10分钟前的时间
针对美国国家安全局“酸狐狸”漏洞攻击武器平台的分析与应对方案建议
防范未授权访问攻击的十项安全措施
利用日志服务器输出各种apache的日志的TOPN
Dm8: generate DM AWR Report
Move blog to CSDN
How to run jenkins build, in multiple servers with ssh-key
19.04 distributor
MySQL advanced 3
大学生研究生毕业找工作,该选择哪个方向?
coredns 修改upstream
数字货币:影响深远的创新
k个一组反转链表
uniapp-第三方网络请求
Use the log server to output the topn of various Apache logs








