Java-Layui使用layExcel导出复杂excel

文章详细描述了如何在Vue前端框架中,利用layExcel库进行Excel文件的导出,包括数据的组织、格式化(如字体大小、对齐方式)、跨行跨列设置以及导出文件的配置过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Java-Layui使用layExcel导出复杂excel

安装

这里使用Vue前端框架来演示Excel导出功能,可通过npm进行安装,代码如下:

$ npm i lay-excel

转载:https://blog.youkuaiyun.com/jiciqiang/article/details/129392965

示例

pushExport () {
    let exportData = [];
    let lineNull = new Array(26).fill("");
    // 第1行
    let line1 = new Array(26).fill("");
    line1[0] = this.formData.airline;
    line1[1] = this.formData.iata;
    line1[2] = this.formData.track;
    line1[23] = this.formData.airline + '-' + this.formData.track;
    exportData.push(line1);
    // 第2行
    exportData.push(lineNull);
    // 第3行
    let line3 = new Array(26).fill("");
    let line3Info1 = this.formData.consignor.name;
    line3[0] = line3Info1;
    line3[15] = this.toUpper(this.formData.airlineInfo.ename);
    exportData.push(line3);
    // 第4行
    exportData.push(lineNull);
    // 第5行
    let line5 = new Array(26).fill("");
    let line5Info = this.formData.consignor.name;
    line5[0] = line5Info;
    exportData.push(line5);
    // 第6行
    let line6 = new Array(26).fill("");
    line6[0] = this.formData.meta.agent;
    line6[22] = this.backPayment();
    exportData.push(line6);
    // 第7行
    exportData.push(lineNull);
    // 第8行
    let line8 = new Array(26).fill("");
    line8[0] = this.formData.iataInfo.airport + ',' + this.formData.iataInfo.country;
    exportData.push(line8);
    // 第9行
    exportData.push(lineNull);
    // 第10行
    let line10 = new Array(26).fill("");
    line10[0] = this.formData.destIata;
    line10[1] = this.formData.airlineInfo.code;
    line10[8] = this.formData.dests.length >0 ? this.formData.dests[0].iata : '';
    line10[9] = this.formData.dests.length > 0 ? this.formData.dests[0].airlineInfo.code : '';
    line10[13] = this.formData.dests.length> 1 ? this.formData.dests[1].iata : '';
    line10[16] = this.formData.dests.length > 1 ? this.formData.dests[1].airlineInfo.code : '';
    line10[18] = this.formData.charge.currency;
    line10[21] = this.formData.charge.payment;
    line10[24] = this.formData.meta.carriage;
    exportData.pus
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值