<script src="http://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.min.js"></script>
<script>
let list = [ { "tuangouCode": "23432fd", "salePrice": 1, "markerPrice": 321, "thridServicePrice": 321, "deductPrice": 321, "orderSourceDetail": 321 }, { "tuangouCode": "212312312d", "salePrice": 4, "markerPrice": 22, "thridServicePrice": 22, "deductPrice": 222, "orderSourceDetail": 2222 } ] if (list.length > 0) { let arr = []; list.map((item) => { let itemArr=[]; itemArr.push(item.orderSourceDetail) itemArr.push(item.tuangouCode) itemArr.push(item.salePrice) itemArr.push(item.thridServicePrice) itemArr.push(item.markerPrice) itemArr.push(item.deductPrice) arr.push(itemArr) }) var aoa = [ ['渠道', '券码', '团购售价金额', '第三方技术服务费', '团购营销费用', '团购金额结算'], ...arr ] console.log(arr) console.log(aoa) var worksheet = XLSX.WorkSheet = XLSX.utils.aoa_to_sheet(aoa); var workbook = XLSX.WorkBook = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1'); XLSX.writeFile(workbook, '团购套餐明细.xls'); } else { tipsClass.show({ msg: "导入成功" }); }
</script>