git官网

安装:

cnpm install --save xlsx file-saver

.vue文件中:
1. 引用table插件/自己写table布局 <el-table ></el-table>
2. 引入依赖

import FileSaver from 'file-saver' 
import XLSX from 'xlsx'

3. 下载功能使用:

exportExcel () {
  /* 从表中生成工作簿对象 */
  var wb = XLSX.utils.table_to_book(document.querySelector('#my-table'))
    /* 获取二进制字符串作为输出 */
    var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
    try {
        /* 存储到本地 */
        FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }),     'sheetjs.xlsx')
    } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
    return wbout;
},

 

详细整理该组件:

 

相关文章:

  • 2021-10-20
  • 2021-11-12
  • 2021-11-21
  • 2021-05-26
  • 2021-06-30
  • 2021-11-07
猜你喜欢
  • 2021-07-13
  • 2021-05-15
  • 2021-08-27
  • 2021-04-11
  • 2021-11-11
  • 2021-08-29
  • 2021-06-13
相关资源
相似解决方案