Loading src/Exceptions/Handler/PhpSpreadsheetExceptionHandler.php +8 −3 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,15 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler public function handle(Throwable $throwable, ResponseInterface $response) public function handle(Throwable $throwable, ResponseInterface $response) { { $error = $throwable->getMessage(); $error = $throwable->getMessage(); if ($throwable instanceof PhpSpreadsheetException) { if (strpos($error, 'Formula Error') !== false) { if (strpos($error, 'Formula Error') !== false) { $msg = '表格公式错误, 请检查是否引用其它表格数据'; $msg = '表格公式错误, 请检查是否引用其它表格数据'; return $this->jsonResponse($msg, $response); return $this->jsonResponse($msg, $response); } } } else if (strpos($error, 'PhpOffice\PhpSpreadsheet\Writer\Xls::writeSummaryProp()') !== false) { $msg = '表格格式兼容错误,请上传 xlsx 结尾的excel'; return $this->jsonResponse($msg, $response); } return $response; return $response; } } Loading @@ -40,7 +45,7 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool { { return $throwable instanceof PhpSpreadsheetException; return true; } } } } Loading
src/Exceptions/Handler/PhpSpreadsheetExceptionHandler.php +8 −3 Original line number Original line Diff line number Diff line Loading @@ -19,10 +19,15 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler public function handle(Throwable $throwable, ResponseInterface $response) public function handle(Throwable $throwable, ResponseInterface $response) { { $error = $throwable->getMessage(); $error = $throwable->getMessage(); if ($throwable instanceof PhpSpreadsheetException) { if (strpos($error, 'Formula Error') !== false) { if (strpos($error, 'Formula Error') !== false) { $msg = '表格公式错误, 请检查是否引用其它表格数据'; $msg = '表格公式错误, 请检查是否引用其它表格数据'; return $this->jsonResponse($msg, $response); return $this->jsonResponse($msg, $response); } } } else if (strpos($error, 'PhpOffice\PhpSpreadsheet\Writer\Xls::writeSummaryProp()') !== false) { $msg = '表格格式兼容错误,请上传 xlsx 结尾的excel'; return $this->jsonResponse($msg, $response); } return $response; return $response; } } Loading @@ -40,7 +45,7 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool { { return $throwable instanceof PhpSpreadsheetException; return true; } } } }