From 38f346661bb281b6252684046ff416632f828aca Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Sun, 31 May 2026 09:26:18 -0700 Subject: [PATCH] Bug in FIXED Function Fix #4889. Function was not outputting correct number of decimals when thousands separator was omitted. --- src/PhpSpreadsheet/Calculation/TextData/Format.php | 7 +++++++ tests/data/Calculation/TextData/FIXED.php | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 23bf74f03..08d022e30 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -103,6 +103,13 @@ class Format StringHelper::getDecimalSeparator(), StringHelper::getThousandsSeparator() ); + } else { + $valueResult = number_format( + $valueResult, + $decimals, + StringHelper::getDecimalSeparator(), + '' + ); } return (string) $valueResult; diff --git a/tests/data/Calculation/TextData/FIXED.php b/tests/data/Calculation/TextData/FIXED.php index e13b8110e..f82b91fb9 100644 --- a/tests/data/Calculation/TextData/FIXED.php +++ b/tests/data/Calculation/TextData/FIXED.php @@ -66,4 +66,6 @@ return [ 'null second argument' => ['123', 123, null], 'false second argument' => ['123', 123, false], 'true second argument' => ['123.0', 123, true], + 'fixed decimals without thousands separator' => ['1507.50', 1507.5, 2, true], + 'fixed decimals with thousands separator' => ['1,507.50', 1507.5, 2, false], ];