vue导出excel表格(包含图片)
1、安装依赖:npm install xlsx。
·
1、安装依赖:npm install xlsx --save
2、引入:

// 导出表格 按钮点击后触发事件
const onBatchExport = () => {
const column = [
//数据表单
{
title: "ID", //表头名称title
key: "id", //数据
type: "text", //类型
},
{
title: "景区ID",
key: "scienceid",
type: "text",
},
{
title: "景区名称",
key: "sciencename",
type: "text",
},
{
title: "二维码",
key: "code",
type: "image",
width: 80,
height: 80,
},
{
title: "二维码状态",
key: "state",
type: "text",
},
{
title: "创建时间",
key: "time",
type: "text",
width: 130,
height: 80,
},
];
//将数据转化为字符串(list_data数据是接口数据,把名称换成自己的数据即可)
let tableDatas = JSON.parse(JSON.stringify(datalists.value));
let datas = tableDatas;
table2excel(column, datas, "数据"); //表单数据名称
};
3、 结果:

更多推荐



所有评论(0)