diff --git a/app/Utils/Excel.php b/app/Utils/Excel.php index 09a4e86..294409c 100644 --- a/app/Utils/Excel.php +++ b/app/Utils/Excel.php @@ -4,6 +4,7 @@ namespace App\Utils; use Exception; use PhpOffice\PhpSpreadsheet\IOFactory; +use PhpOffice\PhpSpreadsheet\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Spreadsheet; use function Hyperf\Config\config; @@ -19,7 +20,7 @@ class Excel $file = BASE_PATH . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR . $file; if (!file_exists($file)) return false; // 显式使用 Xlsx 读取器并配置兼容选项 - $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx(); + $reader = new Xlsx(); // 关键配置:跳过样式/公式等兼容性陷阱 $reader->setReadDataOnly(true); // 只读数据,忽略公式 $reader->setReadEmptyCells(false); // 跳过空单元格处理