diff --git a/docs/topics/recipes.md b/docs/topics/recipes.md index 9df63e7a24..33d218d436 100644 --- a/docs/topics/recipes.md +++ b/docs/topics/recipes.md @@ -415,6 +415,7 @@ At present, the following locale settings are supported: Language | | Locale Code ---------------------|----------------------|------------- +Bulgarian | български | bg Czech | Ceština | cs Danish | Dansk | da German | Deutsch | de diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 6a56309c33..d0e1220348 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -4997,7 +4997,12 @@ private function processTokenStack(mixed $tokens, ?string $cellID = null, ?Cell } } else { $emptyArguments[] = ($arg['type'] === 'Empty Argument'); - $args[] = self::unwrapResult($arg['value']); + if ($arg['type'] === 'Empty Argument' && in_array($functionName, ['MIN', 'MINA', 'MAX', 'MAXA'], true)) { + $args[] = $arg['value'] = 0; + $this->debugLog->writeDebugLog('Empty Argument reevaluated as 0'); + } else { + $args[] = self::unwrapResult($arg['value']); + } if ($functionName !== 'MKMATRIX') { $argArrayVals[] = $this->showValue($arg['value']); } diff --git a/tests/PhpSpreadsheetTests/Calculation/MissingArgumentsTest.php b/tests/PhpSpreadsheetTests/Calculation/MissingArgumentsTest.php new file mode 100644 index 0000000000..8b9b483ac7 --- /dev/null +++ b/tests/PhpSpreadsheetTests/Calculation/MissingArgumentsTest.php @@ -0,0 +1,40 @@ +getActiveSheet(); + $sheet->getCell('A1')->setValue($formula); + self::assertSame($expected, $sheet->getCell('A1')->getCalculatedValue()); + $spreadsheet->disconnectWorksheets(); + } + + public static function providerMissingArguments(): array + { + return [ + 'argument missing at end' => [0, '=min(3,2,)'], + 'argument missing at beginning' => [0, '=mina(,3,2)'], + 'argument missing in middle' => [0, '=min(,3,2)'], + 'missing argument is not result' => [-2, '=min(3,-2,)'], + 'max with missing argument' => [0, '=max(-3,-2,)'], + 'maxa with missing argument' => [0, '=maxa(-3,-2,)'], + 'max with null cell' => [-2, '=max(-3,-2,Z1)'], + 'min with null cell' => [2, '=min(3,2,Z1)'], + 'product ignores null argument' => [6.0, '=product(3,2,)'], + 'embedded function' => [5, '=sum(3,2,min(3,2,))'], + 'unaffected embedded function' => [8, '=sum(3,2,max(3,2,))'], + ]; + } +}