Trap for scientific format masks with "0" or "#" before the "E"

This commit is contained in:
Mark Baker 2013-10-28 19:13:59 +00:00
parent bff907a1b8
commit f86458630f
2 changed files with 2 additions and 2 deletions

View File

@ -283,7 +283,7 @@ class PHPExcel_Shared_Date
if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL)) if (strtolower($pFormatCode) === strtolower(PHPExcel_Style_NumberFormat::FORMAT_GENERAL))
// "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check)
return FALSE; return FALSE;
if (preg_match('/0E[+-]0/i', $pFormatCode)) { if (preg_match('/[0#]E[+-]0/i', $pFormatCode))
// Scientific format // Scientific format
return FALSE; return FALSE;
// Switch on formatcode // Switch on formatcode

View File

@ -673,7 +673,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P
); );
$value = preg_replace($number_regex, $value, $format); $value = preg_replace($number_regex, $value, $format);
} else { } else {
if (preg_match('/0E[+-]0/i', $format)) { if (preg_match('/[0#]E[+-]0/i', $format)) {
// Scientific format // Scientific format
$value = sprintf('%5.2E', $value); $value = sprintf('%5.2E', $value);
} elseif (preg_match('/0([^\d\.]+)0/', $format)) { } elseif (preg_match('/0([^\d\.]+)0/', $format)) {