From f86458630f49fcbe8f1022e6ec352d7c292eb198 Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Mon, 28 Oct 2013 19:13:59 +0000 Subject: [PATCH] Trap for scientific format masks with "0" or "#" before the "E" --- Classes/PHPExcel/Shared/Date.php | 2 +- Classes/PHPExcel/Style/NumberFormat.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index 4bae5f2..0c7bb91 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -283,7 +283,7 @@ class PHPExcel_Shared_Date 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) return FALSE; - if (preg_match('/0E[+-]0/i', $pFormatCode)) { + if (preg_match('/[0#]E[+-]0/i', $pFormatCode)) // Scientific format return FALSE; // Switch on formatcode diff --git a/Classes/PHPExcel/Style/NumberFormat.php b/Classes/PHPExcel/Style/NumberFormat.php index 80347bf..a0688f4 100644 --- a/Classes/PHPExcel/Style/NumberFormat.php +++ b/Classes/PHPExcel/Style/NumberFormat.php @@ -673,7 +673,7 @@ class PHPExcel_Style_NumberFormat extends PHPExcel_Style_Supervisor implements P ); $value = preg_replace($number_regex, $value, $format); } else { - if (preg_match('/0E[+-]0/i', $format)) { + if (preg_match('/[0#]E[+-]0/i', $format)) { // Scientific format $value = sprintf('%5.2E', $value); } elseif (preg_match('/0([^\d\.]+)0/', $format)) {