From fb18b7b59881042de43d54aa74fb9d0b778851ea Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 23 Jan 2015 16:09:36 +0000 Subject: [PATCH] Fix to complex number format signing when mask has a decimal --- Classes/PHPExcel/Style/NumberFormat.php | 4 ++-- unitTests/rawTestData/Style/NumberFormat.data | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Style/NumberFormat.php b/Classes/PHPExcel/Style/NumberFormat.php index 39e5dfa..62ab3e2 100644 --- a/Classes/PHPExcel/Style/NumberFormat.php +++ b/Classes/PHPExcel/Style/NumberFormat.php @@ -505,8 +505,8 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P $numbers = explode('.', $number . '.0'); $masks = explode('.', $mask . '.0'); $result1 = self::_complexNumberFormatMask($numbers[0], $masks[0], 1); - $result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1])), 1); - return $result1 . '.' . $result2; + $result2 = strrev(self::_complexNumberFormatMask(strrev($numbers[1]), strrev($masks[1]), 1)); + return (($sign) ? '-' : '') . $result1 . '.' . $result2; } $r = preg_match_all('/0+/', $mask, $result, PREG_OFFSET_CAPTURE); diff --git a/unitTests/rawTestData/Style/NumberFormat.data b/unitTests/rawTestData/Style/NumberFormat.data index 08a0d6a..49acacc 100644 --- a/unitTests/rawTestData/Style/NumberFormat.data +++ b/unitTests/rawTestData/Style/NumberFormat.data @@ -33,3 +33,5 @@ 123456789, '0 (+00) 0000 00 00 00', "0 (+00) 0123 45 67 89" 123456789, '0000:00:00', "12345:67:89" -123456789, '0000:00:00', "-12345:67:89" +1234567.89, '0000:00.00', "12345:67.89" +-1234567.89,'0000:00.00', "-12345:67.89"