vue.js中使用Export2Excel导出Excel表格
作者:chrispy
// 导出的方法
loadingFun () {
loadingInstance = Loading.service(options)
this.dowExcelList = []
this.getExportExcelData()
},
async getExportExcelData () {
this.dowCurrentPage++
const params = `?tenantId=${this.search.tenantId}&projectId=${this.search.projectId}&createTimeStart=${this.search.createTimeStart}
&createTimeEnd=${this.search.createTimeEnd}&identity=${this.search.identity}&sort=${this.search.sort}
&pageSize=10¤tPage=${this.dowCurrentPage}`
const result = await getDownStatisticsGetAgentRankList(params)
this.dowExcelList = this.dowExcelList.concat(result.data)
if (this.dowCurrentPage < result.page.pageCount) {
let totalPage = result.page.pageCount
let currentPage = result.page.currentPage
let Speed = parseInt((currentPage / totalPage) * 100)
loadingInstance.text = `导出进度 ${Speed}%`
this.getExportExcelData(params)
} else {
this.export2Excel()
}
},
export2Excel () {
loadingInstance.text = `导出进度完成开始下载`
require.ensure([], () => {
const { exportJsonToExcel } = require('../../vendor/Export2Excel')
const tHeader = ['渠道身份', '姓名', '全部报备'] // 上面设置Excel的表格第一行的标题
const filterVal = ['identityname', 'name', 'allNum'] // 上面的index、nickName、name是tableData里对象的属性
const list = this.dowExcelList // 把data里的tableData存到list
const data = this.formatJson(filterVal, list)
exportJsonToExcel(tHeader, data, '列表excel')
})
setTimeout(() => {
loadingInstance.close()
}, 500)
},
formatJson (filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => v[j]))
}
猜你喜欢
您可能感兴趣的文章:
- php工程师面试题
- php工程师面试题2
- PHP面试题,PHP程序员面试题及答案
- php数组分页
- php四舍五入函数round()
- PHP中$_SERVER的详细参数与说明
- PHP中mysql_connect与mysql_pconnect的区别
- php中print_r、var_dump和var_export
- PHP中strtr和str_replace比较
- Elasticsearch 中文或字符串不支持精准搜索
- mysql 替换replace
- vue 渐隐效果
- axios 拦截器
- 安装 vant
- 数组去重
- 对比两个数组,找出不同的值,返回新的数组
- nodejs配置本地转发
- 获取当前时间年月日时分秒 格式:20001212120000
- 常用属性