diff --git a/Classes/PHPExcel/Style/NumberFormat.php b/Classes/PHPExcel/Style/NumberFormat.php index 3d5b20e1..80347bf9 100644 --- a/Classes/PHPExcel/Style/NumberFormat.php +++ b/Classes/PHPExcel/Style/NumberFormat.php @@ -673,7 +673,10 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P ); $value = preg_replace($number_regex, $value, $format); } else { - if (preg_match('/0([^\d\.]+)0/', $format, $matches)) { + if (preg_match('/0E[+-]0/i', $format)) { + // Scientific format + $value = sprintf('%5.2E', $value); + } elseif (preg_match('/0([^\d\.]+)0/', $format)) { $value = self::_complexNumberFormatMask($value, $format); } else { $sprintf_pattern = "%0$minWidth." . strlen($right) . "f"; diff --git a/unitTests/rawTestData/Calculation/TextData/TEXT.data b/unitTests/rawTestData/Calculation/TextData/TEXT.data index 3087dfaa..da18defa 100644 --- a/unitTests/rawTestData/Calculation/TextData/TEXT.data +++ b/unitTests/rawTestData/Calculation/TextData/TEXT.data @@ -1,10 +1,13 @@ -123.456, '"$#,##0.00"', "$123.46" -123.456, '"#,##0.00"', "123.46" -123.456, '"#,##0"', "123" -123.456, "00000", "00123" -123456.789, '"$#,##0.00"', '"$123,456.79"' -123456.789, '"#,##0.00"', '"123,456.79"' -123456.789, "0.00E+00", "1.23E05" +123.456, '"$#,##0.00"', "$123.46" +-123.456, '"$#,##0.00"', "$-123.46" +123.456, '"#,##0.00"', "123.46" +123.456, '"#,##0"', "123" +123.456, "00000", "00123" +123456.789, '"$#,##0.00"', '"$123,456.79"' +123456.789, '"#,##0.00"', '"123,456.79"' +123456.789, "0.00E+00", "1.23E05" +-123456.789, "0.00E+00", "-1.23E05" +0.000012345, "0.00E+00", "1.23E-05" "19-Dec-1960", "yyyy-mm-dd", "1960-12-19" "1-Jan-2012", "yyyy-mm-dd", "2012-01-01" -1.75, "# ?/?", "1 3/4" +1.75, "# ?/?", "1 3/4"