` // 导出excel

  const length = this.columnOptions.length - 1;// 一级表头的长度
  let sHeader = [];
  let h1 = []; // 类别项
  for (let i = 0; i < this.tableHeader.length; i++) {
    let arr = [];
    if (length == 5 || this.homeData.type == 999) {
      arr = [this.tableHeader[i].typeValueName, '', '', ''];
    } else {
      arr = [this.tableHeader[i].typeValueName, '', ''];
    } 
    h1 = h1.concat(arr);
    sHeader = this.tableItem.map(h => h.label).concat(sHeader);
  }
  const header = Array(length).fill('').concat(sHeader);// 二级表内容
  const fHeader = this.columnOptions.filter(h => h.label).map(i => i.label);
  const multiHeader = [fHeader.concat(h1)]; // 多级表头
  const data = [];// 传入的数据
  const filterVal = this.columnOptions.filter(p => p.prop).map(i => i.prop); // 表头名
  for (let i = 0; i < this.listData.length; i++) {
    const data1 = [].concat.apply([], this.formatJson(this.tableItem.map(h => h.prop), this.listData[i].customReportPoList));// 二级表数据
    data[i] = this.formatJson(filterVal, this.listData)[i].concat(data1);
  }
  console.log(data, 'data');
  // 合并excel中的列
  const merges = [];
  for (var i = 0; i < length; i++) {
    const p = `${String.fromCharCode((65 + i))}1:${String.fromCharCode((65 + i))}2`;
    merges.push(p);
  }
  let p1 = '';
  for (let k = 0; k < (data[0].length - length) / this.tableItem.length; k++) {
    let m = length;
    m = m + k * this.tableItem.length;
    p1 = `${m < 26 ? String.fromCharCode((65 + m)) : (m - 26 < 26) ? 'A' + String.fromCharCode((65 + m - 26)) : 'B' + String.fromCharCode((65 + m - 52))}1:${m + this.tableItem.length - 1 < 26 ? String.fromCharCode((65 + m + this.tableItem.length - 1)) : (m - 26 + this.tableItem.length - 1 < 26) ? 'A' + String.fromCharCode((65 + m - 26 + this.tableItem.length - 1)) : 'B' + String.fromCharCode((65 + m - 52 + this.tableItem.length))}1`;
    merges.push(p1);
  }
  import('@/vendor/Export2Excel').then(excel => {
    excel.export_json_to_excel({
      multiHeader,
      header,
      data,
      merges,
      filename: this.title
    });`

冰格儿
143 声望12 粉丝