From 8218d04b0f6ee8f06ba82b891d3acb14ceb7370c Mon Sep 17 00:00:00 2001 From: Mark Baker Date: Thu, 10 Feb 2011 12:26:50 +0000 Subject: [PATCH] Bugfix: Reduced false positives from isDateTimeFormatCode() method by suppressing testing within quoted strings (thanks to John Machin, author of xlrd, and the maintainer of xlwt for reading/writing Excel files in Python) git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@68308 2327b42d-5241-43d6-9e2a-de5ac946f064 --- Classes/PHPExcel/Shared/Date.php | 12 ++++++++++++ changelog.txt | 1 + 2 files changed, 13 insertions(+) diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index 065ebe79..5150dfeb 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -262,6 +262,18 @@ class PHPExcel_Shared_Date } // Try checking for any of the date formatting characters that don't appear within square braces if (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$pFormatCode)) { + // We might also have a format mask containing quoted strings... + // we don't want to test for any of our characters within the quoted blocks + if (strpos($pFormatCode,'"') !== false) { + $i = false; + foreach(explode('"',$pFormatCode) as $subVal) { + // Only test in alternate array entries (the non-quoted blocks) + if (($i = !$i) && (preg_match('/(^|\])[^\[]*['.self::$possibleDateFormatCharacters.']/i',$subVal))) { + return true; + } + } + return false; + } return true; } diff --git a/changelog.txt b/changelog.txt index 29cf7245..054ae6f4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -59,6 +59,7 @@ Fixed in SVN: Default row argument for all __ByColumnAndRow() methods should be 1 - Bugfix: (MBaker) Work item 15121 - Column reference rather than cell reference in Print Area definition Fix Excel2007 Writer to handle print areas that are defined as row or column ranges rather than just as cell ranges +- Bugfix: (MBaker) Reduced false positives from isDateTimeFormatCode() method by suppressing testing within quoted strings - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer. - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.