
Vue中纯前端导出简单Excel表格的方法(使用vue-json-excel插件)前言
使用方法
npm install vue-json-excel
cnpm install vue-json-excel
import Vue from 'vue'import JsonExcel from 'vue-json-excel'Vue.component('downloadExcel', JsonExcel)
<download-excel:data = "json_data":fields = "json_fields"name = "用户统计列表">导出Excel</download-excel>
:fields = “json_fields” ----------------Excel中表头的名称
:data = “json_data” -------------------导出的数据
export default{data(){return{json_fields: { 导出Excel表格的表头设置'序号': 'type','姓名': 'userName','年龄': 'age','手机号': 'phone','注册时间': 'createTime',},}}}
export default{ data(){ return{ json_data:[ {"userName":"张三","age":18,"gender":"phone":15612345612,"createTime":"2019-10-22"}, {"userName":"李四","age":17,"gender":"phone":15612345613,"createTime":"2019-10-23"}, {"userName":"王五","age":19,"gender":"phone":15612345615,"createTime":"2019-10-25"}, {"userName":"赵六","age":18,"gender":"phone":15612345618,"createTime":"2019-10-15"}, ] } }}

<el-button v-if="isExport" @click="nodaochuBtn()" type="primary">导出Excel</el-button><download-excel v-else class="blueBtn" :data="json_data" :fields = "json_fields" worksheet = "My Worksheet" name = "用户信息列表">导出Excel</download-excel>



for(let i in this.json_data){ this.json_data[i].type=parseInt(i)+1 }



总结
图文 来源网络
版权归原作者所有,侵联删



碧茂课堂精彩课程推荐:
1.Cloudera数据分析课;
2.Spark和Hadoop开发员培训;
3.大数据机器学习之推荐系统;
4.Python数据分析与机器学习实战;

详情请关注我们公众号:碧茂大数据-课程产品-碧茂课堂
现在注册互动得海量学币,大量精品课程免费送!

关注最新行业动态,
加群进行技术交流!
文章转载自碧茂大数据,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




