浏览代码

去除空行

cqp 3 月之前
父节点
当前提交
e294eb628b
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      app/Service/ImportService.php

+ 5 - 1
app/Service/ImportService.php

@@ -299,7 +299,11 @@ class ImportService extends Service
 //                        $rowData[] = $cellData;
                     }
 
-                    $sheetData[] = $rowData;
+                    // 判断该行是否是“全空行”:所有单元格都为空字符串或 null
+                    if (! empty(array_filter($rowData, function($v) { return $v !== '' && $v !== null; }))) {
+                        $sheetData[] = $rowData; // 不是空行才添加进去
+                    }
+//                    $sheetData[] = $rowData;
                 }
 
                 // 将当前工作表的数据添加到总数据数组中