girf-export-excel
v1.0.2
Published
girf-export-excel
Downloads
5
Readme
优化 iViewUI 中 Table 导出功能:增加 xlsx 后缀格式支持
安装
npm i girf-export-excel
或
yarn add girf-export-excel使用
[ template ] 部分
<template> <div> ... <a href="javascript:void(0)" @click="exportData()">导出</a> <!-- 组件:导出数据到Excel表格--> <excel-export :params="componentExcelExport.params"></excel-export> ... </div> </template> <script> import ExcelExport from 'girf-export-excel' export default { components: { ExcelExport }, data () { return { // 组件:Excel导出配置 componentExcelExport: { params: { start: false, // 导出开始 data: [], // 导出需要的数据 name: '' // 导出名称 } } } }, methods: { exportData() { let _data = [ { title: '标题', type: '类别', count: '浏览量', times: '时间', status: '状态' } ] _data.push({ title: '长颈鹿英语ABC', type: '英语', count: 100, time: '2020-03-11', status: '已读' }) _data.push({ title: '长颈鹿英语EFG', type: '英语', count: 100, time: '2020-03-11', status: '已读' }) let _name = '数据-'+ new Date().valueOf() this.componentExcelExport.params = { start: true, data: _data, name: _name } } } } </script>参数
|
Key|Desc| | ------------- | ---------------------- | |params| 参数配置,类型Object| |params.start| 使用导出功能的开关,类型Bool| |params.data| 导出的数据,类型Array,第一条数据是表头,其他都为实际数据 | |params.name| 导出文件名,类型String,无需后缀 |
