From b6fe64e62940f73d7bfec5f87a1c07984fb9b11f Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Tue, 16 Dec 2025 15:57:36 +0800 Subject: [PATCH] update --- app/Exports/CommonExport.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/Exports/CommonExport.php b/app/Exports/CommonExport.php index 053dd22..1c982ff 100755 --- a/app/Exports/CommonExport.php +++ b/app/Exports/CommonExport.php @@ -396,10 +396,19 @@ class CommonExport implements FromCollection, WithStyles, WithColumnWidths, With $header = array_values($this->fields); $moreFileds = []; if (empty($clear)) { - if (isset($this->data[0]['data']) && is_array($this->data[0]['data'])) { - $moreHeader = array_column($this->data[0]['data'], 'name'); + // 容错,取前三个数据 + $otherData = ($this->data[0]['data'] ?? null); + if (empty($otherData)) { + $otherData = ($this->data[1]['data'] ?? null); + if (empty($otherData)) { + $otherData = ($this->data[2]['data'] ?? null); + } + } + + if (isset($otherData) && is_array($otherData)) { + $moreHeader = array_column($otherData, 'name'); $header = array_merge($header, $moreHeader); - $moreFileds = array_column($this->data[0]['data'], 'field'); + $moreFileds = array_column($otherData, 'field'); } } $newList[] = $header;