From 79f5cf99f68637b4e0db70eb1307e62e570300b8 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 17 May 2022 12:56:21 +0200 Subject: [PATCH 1/2] Resolve Issue #2833, NULL value handling in PRODUCT() Excel function --- .../Calculation/MathTrig/Operations.php | 2 +- tests/data/Calculation/MathTrig/PRODUCT.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php index 7fd30233..44e13526 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php @@ -108,7 +108,7 @@ class Operations // Loop through arguments foreach (Functions::flattenArray($args) as $arg) { // Is it a numeric value? - if (is_numeric($arg)) { + if (is_numeric($arg) || $arg === null) { if ($returnValue === null) { $returnValue = $arg; } else { diff --git a/tests/data/Calculation/MathTrig/PRODUCT.php b/tests/data/Calculation/MathTrig/PRODUCT.php index 0e7c4080..ab500953 100644 --- a/tests/data/Calculation/MathTrig/PRODUCT.php +++ b/tests/data/Calculation/MathTrig/PRODUCT.php @@ -48,6 +48,18 @@ return [ -6.7800000000000002, -2, ], + [ + 0, + 12.5, + null, + 2.5, + ], + [ + 0, + 12.5, + 2.5, + null, + ], ['#VALUE!', 1, 'y', 3], [6, 1, '2', 3], ]; From 2b9b42d5c64e695921e54bd0352225b221605464 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Tue, 17 May 2022 13:03:52 +0200 Subject: [PATCH 2/2] Update Change Log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f60d7425..53d6c312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org). ### Fixed - Xls Reader resolving absolute named ranges to relative ranges [Issue #2826](https://github.com/PHPOffice/PhpSpreadsheet/issues/2826) [PR #2827](https://github.com/PHPOffice/PhpSpreadsheet/pull/2827) +- Null value handling in the Excel Math/Trig PRODUCT() function [Issue #2833](https://github.com/PHPOffice/PhpSpreadsheet/issues/2833) [PR #2834](https://github.com/PHPOffice/PhpSpreadsheet/pull/2834) ## 1.23.0 - 2022-04-24