<el-button
type="warning"
icon="el-icon-download"
size="small"
@click="onBatchExport"
>
导出
</el-button>
安装插件
npm install js-table2excel
导入插件
import table2excel from 'js-table2excel'
data(){
return {
listDatanew: []
}
}
// 导出事件 datas是接口返回的数据
onBatchExport() {
const column = [
{
title: '姓名',
key: 'name',
type: 'text'
},
{
title: '年龄',
key: 'age',
type: 'text'
},
{
title: '巡检时间',
key: 'XJDATE',
type: 'text'
},
{
title: '问题描述',
key: 'PROBLEM',
type: 'text'
},
{
title: '图片1',
key: 'IMG1',
type: 'image',
width: 50,
height: 50
},
{
title: '图片2',
key: 'IMG2',
type: 'image',
width: 50,
height: 50
},
]
let tableDatas = JSON.parse(JSON.stringify(this.listDatanew))
let datas = tableDatas;
table2excel(column, datas, '导出后的文件名')
},
vue table表格导出图片到Excel
ratel️2023-11-04 12:21
相关推荐
l1t24 分钟前
DeepSeek v4辅助生成的单文件SQL查询示例页面笋笋~1 小时前
el-tree 拖拽事件隔离:实现句柄独立控制,区域分离前端那点事1 小时前
Vue生命周期速查:Vue2+Vue3钩子全解析,新手也能秒懂Aotman_2 小时前
Element UI 表格搜索高亮Dillon Dong3 小时前
【系列主题】拯救 OOM 与构建中断:Next.js 在 Docker 中的静态生成(SSG)避坑指南han_hanker3 小时前
下拉模糊搜索多选, 编辑,详情问题yqcoder3 小时前
[特殊字符] Vue 3 中 Keep-Alive 对生命周期的影响:深度解析jiayong233 小时前
第 33 课:任务看板视图(按状态分列)与本地持久化Yeats_Liao4 小时前
后台 Sidebar 伸缩交互(PC + 移动端)实现MXN_小南学前端4 小时前
computed 计算属性详解:触发时机、实战场景、Vue2 与 Vue3 对比