Commit 27f71ded authored by 王源's avatar 王源 🎧

[功能]添加xls报错处理

parent aec98c47
......@@ -19,8 +19,13 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler
public function handle(Throwable $throwable, ResponseInterface $response)
{
$error = $throwable->getMessage();
if (strpos($error, 'Formula Error') !== false) {
$msg = '表格公式错误, 请检查是否引用其它表格数据';
if ($throwable instanceof PhpSpreadsheetException) {
if (strpos($error, 'Formula Error') !== false) {
$msg = '表格公式错误, 请检查是否引用其它表格数据';
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;
......@@ -40,7 +45,7 @@ class PhpSpreadsheetExceptionHandler extends ExceptionHandler
public function isValid(Throwable $throwable): bool
{
return $throwable instanceof PhpSpreadsheetException;
return true;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment