在vue3中如何制作导出数据Excel(1)

在Vue 3项目中安装和使用 js-table2excel 可以通过以下步骤进行:

  1. 首先,确保你的项目是基于Vue 3创建的。

  2. 使用npm或者yarn安装 js-table2excel 库:
    安装一下

    npm install js-table2excel

    # 或者

    yarn add js-table2excel、
     

        const Value_Data=[{
                    title:'某人'
                }]
        const fun=()=>{
    
            const column = [
    				//数据表单
    				{
    					title: "序号", //表头名称title
    					key: "id", //数据
    					type: "text", //类型
    				},
    				{
    					title: "用户姓名",
    					key: "name",
    					type: "text",
    				},
    				{
    					title: "用户昵称",
    					key: "nickname",
    					type: "text",
    				},
    				{
    					title: "用户头像",
    					key: "imgs",
    					type: 'image',
    					width: 80,
    					height: 80,
    				},
    				{
    					title: "手机号",
    					key: "tel",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    
    				{
    					title: "商品名称",
    					key: "ticketName",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "商品状态",
    					key: 'sheng',
    					type: "text",
    					width: 130,
    					height: 80,
    				}
    				,
    				{
    					title: "支付状态",
    					key: "shen",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "订单号",
    					key: "orderNum",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "支付金额",
    					key: "money",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "商品价格",
    					key: "ticketPrice",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "支付日期",
    					key: "pay_time",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "过期日期",
    					key: "over_time",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    				{
    					title: "下单日期",
    					key: "create_time",
    					type: "text",
    					width: 130,
    					height: 80,
    				},
    			];
            
    			let tableDatas = JSON.stringify(Value_Data.value);
    			let datas = tableDatas;
    			table2excel(column, datas, "订单导出"); //表单数据名称
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值