vue table表格导出图片到Excel

复制代码
<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, '导出后的文件名')
    },
相关推荐
sunly_34 分钟前
React useActionState 的用法详解
前端·javascript·react.js
cyadyx1 小时前
【Three.js】Three.js 中加载 3D 模型
前端·javascript·3d
汉堡大王95271 小时前
前端工程师 TypeScript 上手指南:一条清晰的从入门到精通路线
前端·javascript·react.js
wear工程师2 小时前
防抖为什么会失效?React 面试里的闭包和定时器
javascript·react.js
浅水壁虎2 小时前
vue基础(第四章 Pinia)
前端·javascript·vue.js
张元清2 小时前
React useEventSource Hook:自带断线重连的 Server-Sent Events (2026)
javascript·react.js
学习星球3 小时前
Vue 3 实战:拆解 RealWorld 项目
前端·vue.js
铁皮饭盒3 小时前
网页端, 6.5MB人脸识别模型, 谷歌框架, 又快又准
前端·javascript·后端
自进化Agent智能体3 小时前
Hermes 工具与工具集——Hermes 的内置能力
javascript
你挚爱的强哥4 小时前
【exportExcel】单纯靠js不用任何其他第三方插件导出xls格式文件
开发语言·javascript·ecmascript