diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 0ec396f6e3..a645d790a4 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -153,7 +153,7 @@ public static function ifCondition($condition): string { $condition = self::flattenSingleValue($condition); - if ($condition === '') { + if ($condition === '' || $condition === null) { return '=""'; } if (!is_string($condition) || !in_array($condition[0], ['>', '<', '='], true)) { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3613Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3613Test.php new file mode 100644 index 0000000000..71899039e4 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3613Test.php @@ -0,0 +1,25 @@ +load(self::$testbook); + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx'); + $spreadsheet->disconnectWorksheets(); + $sheet = $reloadedSpreadsheet->getActiveSheet(); + self::assertSame('=ROUND(MAX((O4-P4)*{0.03;0.1;0.2;0.25;0.3;0.35;0.45}-{0;2520;16920;31920;52920;85920;181920},0)-Q4,2)', $sheet->getCell('N4')->getValue()); + + $reloadedSpreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Reader/XLSX/issue.3613.xlsx b/tests/data/Reader/XLSX/issue.3613.xlsx new file mode 100644 index 0000000000..4b1296fee7 Binary files /dev/null and b/tests/data/Reader/XLSX/issue.3613.xlsx differ