xlsx.js导出复杂表格(多表头,嵌套数据)?

新手上路,请多包涵
     orderTable: [
        {
          supplierId: 1,
          supplierName: '张三',
          orderId: 1,
          creator: '墨子',
          createTime: "2023/4/5",
          orderStatus: "进行中",
          instmName: '剪子',
          qxNum: 2,
          gudingPrice: 10,
          zhiruList: [
            { itemid: 1, itemName: "物品1", itemPrice: 10, itemNum: 1 },
            { itemid: 2, itemName: "物品2", itemPrice: 10, itemNum: 2 },
          ],
          xiaoji: 10,
          zongji: 10
        }, {
          supplierId: 1,
          supplierName: '张三',
          orderId: 1,
          creator: 'jian',
          createTime: "2023/4/5",
          orderStatus: "进行中",
          instmName: 'ddd',
          qxNum: 2,
          gudingPrice: 10,
          zhiruList: [
            { itemid: 1, itemName: "物品1", itemPrice: 10, itemNum: 1 },
            { itemid: 2, itemName: "物品2", itemPrice: 10, itemNum: 2 },
          ],
          xiaoji: 10,
          zongji: 10
        },
        {
          supplierId: 2,
          supplierName: '张三',
          orderId: 2,
          creator: '赤炼',
          createTime: "2023/4/5",
          orderStatus: "进行中",
          instmName: '剑子',
          qxNum: 1,
          gudingPrice: 10,
          zhiruList: [
            { itemid: 1, itemName: "物品1", itemPrice: 10, itemNum: 1 },
            { itemid: 2, itemName: "物品2", itemPrice: 10, itemNum: 2 },
            { itemid: 1, itemName: "物品1", itemPrice: 10, itemNum: 1 },
          ],
          xiaoji: 10,
          zongji: 10
        }
      ],

用xlsx.js导出以上结构,表头部分:一级表头zhiruList下嵌套三个二级表头:itemName,itemPrice,itemNum,每行数据中嵌套一个数组

阅读 1.9k
2 个回答

如何可以换库的话,可以尝试下 @zurmokeeper/exceljs , 直接内置了导出时设置多表头的API,worksheet.makeColumns 方法,link:

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题