diff --git a/app/helpers.php b/app/helpers.php index 4c459fa..fbb6783 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -613,10 +613,10 @@ function ($markdowns, $tableName, $tableComment) { - - - - + + + + {$html} @@ -791,7 +791,7 @@ function processSpreedSheetSingle($contentArray, $minRow, $minCol) $cells = $item['cells'] ?? []; $lastIndex = count($cells); if ($lastIndex === 0) { - return $item; + return 0; } for ($i = $lastIndex; $i > 0; $i--) { @@ -831,33 +831,22 @@ function processSpreedSheetSingle($contentArray, $minRow, $minCol) */ function processSpreedSheetRows($originalRows): array { - // 提取行的元信息 - $rows = collect($originalRows)->filter(function ($item, $key) { - return !is_numeric($key); - })->toArray(); - // 每一行的数据 - $rowsForCol = collect($originalRows)->filter(function ($item, $key) { - return is_numeric($key); - })->sortKeys()->toArray(); - - // 逆序遍历行,直到遇到第一个存在非空列的行未知,截取从第一行开始到当前行 - $lastIndex = count($rowsForCol); - if ($lastIndex > 0) { - for ($i = $lastIndex; $i > 0; $i--) { - $colCount = collect($rowsForCol[$i]['cells'] ?? [])->filter(function ($cell) { - return !empty($cell['text']); - })->count(); - - if ($colCount > 0) { - foreach (array_slice($rowsForCol, 0, $i + 1) as $index => $v) { - $rows["{$index}"] = $v; + return collect($originalRows)->filter(function ($item, $key) { + // 保留行元信息 + if (!is_numeric($key)) { + return true; + } + else { + foreach ($item['cells'] as $k => $v) { + if (is_numeric($k) && !empty($v['text'])) { + // 保留非空行数据 + return true; } - - break; } + // 过滤空行数据 + return false; } - } - return $rows; + })->toArray(); } /**
字段类型说明字段类型说明