diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index e6e6921549..6028a9d72f 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3729,6 +3729,8 @@ private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller self::resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } + [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1); + [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2); return [$matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns]; } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProduct2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProduct2Test.php new file mode 100644 index 0000000000..0d40b5dd92 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumProduct2Test.php @@ -0,0 +1,34 @@ +load($file); + $sheet = $spreadsheet->getActiveSheet(); + self::assertSame('=SUMPRODUCT(((calNames=I3)*(calTiers=$K$2))*calHours)', $sheet->getCell('K3')->getValue()); + self::assertSame(40, $sheet->getCell('K3')->getCalculatedValue()); + self::assertSame(4, $sheet->getCell('L3')->getCalculatedValue()); + self::assertSame(40, $sheet->getCell('M3')->getCalculatedValue()); + self::assertSame(4, $sheet->getCell('N3')->getCalculatedValue()); + self::assertSame(40, $sheet->getCell('K4')->getCalculatedValue()); + self::assertSame(0, $sheet->getCell('L4')->getCalculatedValue()); + self::assertSame(40, $sheet->getCell('M4')->getCalculatedValue()); + self::assertSame(0, $sheet->getCell('N4')->getCalculatedValue()); + self::assertSame(24, $sheet->getCell('K5')->getCalculatedValue()); + self::assertSame(0, $sheet->getCell('L5')->getCalculatedValue()); + self::assertSame(24, $sheet->getCell('M5')->getCalculatedValue()); + self::assertSame(0, $sheet->getCell('N5')->getCalculatedValue()); + self::assertSame('=SUMPRODUCT(calHours*((calNames=I3)*(calTiers=$K$2)))', $sheet->getCell('I14')->getValue()); + self::assertSame(40, $sheet->getCell('I14')->getCalculatedValue()); + $spreadsheet->disconnectWorksheets(); + } +} diff --git a/tests/data/Reader/XLSX/issue.3909b.xlsx b/tests/data/Reader/XLSX/issue.3909b.xlsx new file mode 100644 index 0000000000..8b16d5610c Binary files /dev/null and b/tests/data/Reader/XLSX/issue.3909b.xlsx differ