Bootstrap

element-UI库Table表格导出Excel表格

Element组件库中的el-table表格导出需要的主要是两个依赖:(xlsx 和 file-saver)

安装:

npm install --save xlsx file-saver

两个插件的详情地址:
https://github.com/SheetJS/js-xlsx
https://github.com/eligrey/FileSaver.js

代码:

<template>
    <div class="table">
        <!--给表格添加一个id,导出文件事件需要使用-->
        <el-table
        :data="tableData"
        border
        style="width: 100%"
        id="out-table"
        >
        <el-table-column
            prop="date"
            label="日期"
            width="180"
        >
        </el-table-column>
        <el-table-column
            prop="name"
            label="姓名"
            width="180"
 
;