diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index cc8ef327..da72e763 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -42,12 +42,12 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) { // Cell reference (cell or range of cells, with or without a sheet reference) define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})'); // Named Range of cells - define('CALCULATION_REGEXP_NAMEDRANGE','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9]*)'); + define('CALCULATION_REGEXP_NAMEDRANGE','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)'); } else { // Cell reference (cell or range of cells, with or without a sheet reference) define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)'); // Named Range of cells - define('CALCULATION_REGEXP_NAMEDRANGE','(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9]*)'); + define('CALCULATION_REGEXP_NAMEDRANGE','(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)'); } } @@ -55,9 +55,9 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) { /** * PHPExcel_Calculation (Singleton) * - * @category PHPExcel - * @package PHPExcel_Calculation - * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) + * @category PHPExcel + * @package PHPExcel_Calculation + * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) */ class PHPExcel_Calculation { @@ -69,7 +69,7 @@ class PHPExcel_Calculation { const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'; // Opening bracket const CALCULATION_REGEXP_OPENBRACE = '\('; - // Function + // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it) const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\('; // Cell reference (cell or range of cells, with or without a sheet reference) const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; diff --git a/Classes/PHPExcel/ReferenceHelper.php b/Classes/PHPExcel/ReferenceHelper.php index 63a000fe..98819b2e 100644 --- a/Classes/PHPExcel/ReferenceHelper.php +++ b/Classes/PHPExcel/ReferenceHelper.php @@ -137,7 +137,8 @@ class PHPExcel_ReferenceHelper if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { // Formula should be adjusted $pSheet->getCell($newCoordinates) - ->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); + ->setValue($this->updateFormulaReferences($cell->getValue(), + $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); } else { // Formula should not be adjusted $pSheet->getCell($newCoordinates)->setValue($cell->getValue()); @@ -145,6 +146,16 @@ class PHPExcel_ReferenceHelper // Clear the original cell $pSheet->getCell($cell->getCoordinate())->setValue(''); + + } else { + /* We don't need to update styles for rows/columns before our insertion position, + but we do still need to adjust any formulae in those cells */ + if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { + // Formula should be adjusted + $cell->setValue($this->updateFormulaReferences($cell->getValue(), + $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); + } + } } diff --git a/Classes/PHPExcel/Shared/Date.php b/Classes/PHPExcel/Shared/Date.php index 5150dfeb..6b4e2fcb 100644 --- a/Classes/PHPExcel/Shared/Date.php +++ b/Classes/PHPExcel/Shared/Date.php @@ -220,7 +220,7 @@ class PHPExcel_Shared_Date } // function isDateTimeFormat() - private static $possibleDateFormatCharacters = 'ymdHis'; + private static $possibleDateFormatCharacters = 'ymdHs'; /** * Is a given number format code a date/time? diff --git a/changelog.txt b/changelog.txt index fdbf4d64..02dc7603 100644 --- a/changelog.txt +++ b/changelog.txt @@ -62,9 +62,13 @@ Fixed in SVN: - 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 -- Bugfix: (MBaker) Work item 15312 - Caching and tmp partition exhaustion +- Bugfix: (MBaker) Work item 15312 - Caching and tmp partition exhaustion - Bugfix: (MBaker) Work item 15308 - Writing to Variable No Longer Works. $_tmp_dir Missing in PHPExcel\PHPExcel\Shared\OLE\PPS\Root.php +- Bugfix: (MBaker) Work item 15379 - Named ranges with dot don't get parsed properly +- Bugfix: (MBaker) Work item 15096 - insertNewRowBefore fails to consistently update references +- Bugfix: (MBaker) "i" is not a valid character for Excel date format masks (in isDateTimeFormatCode() method) - General: (MBaker) Improved performance (speed), for building the Shared Strings table in the Excel2007 Writer. +- General: (MBaker) Improved performance (speed), for PHP to Excel date conversions - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.