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