Bugfix: Work item 15379 - Named ranges with dot don't get parsed properly

Bugfix:	Work item 15096 - insertNewRowBefore fails to consistently update references
Bugfix:	"i" is not a valid character for Excel date format masks (in isDateTimeFormatCode() method)


git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@69064 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-02-21 12:21:20 +00:00
parent 2dcead065d
commit a8517724dc
4 changed files with 24 additions and 9 deletions

View File

@ -42,12 +42,12 @@ if (!defined('CALCULATION_REGEXP_CELLREF')) {
// Cell reference (cell or range of cells, with or without a sheet reference) // 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})'); define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
// Named Range of cells // 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 { } else {
// Cell reference (cell or range of cells, with or without a sheet reference) // Cell reference (cell or range of cells, with or without a sheet reference)
define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)'); define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)');
// Named Range of cells // 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) * PHPExcel_Calculation (Singleton)
* *
* @category PHPExcel * @category PHPExcel
* @package PHPExcel_Calculation * @package PHPExcel_Calculation
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel) * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
*/ */
class PHPExcel_Calculation { class PHPExcel_Calculation {
@ -69,7 +69,7 @@ class PHPExcel_Calculation {
const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'; const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"';
// Opening bracket // Opening bracket
const CALCULATION_REGEXP_OPENBRACE = '\('; 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]*\('; const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\(';
// Cell reference (cell or range of cells, with or without a sheet reference) // Cell reference (cell or range of cells, with or without a sheet reference)
const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF; const CALCULATION_REGEXP_CELLREF = CALCULATION_REGEXP_CELLREF;

View File

@ -137,7 +137,8 @@ class PHPExcel_ReferenceHelper
if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) { if ($cell->getDataType() == PHPExcel_Cell_DataType::TYPE_FORMULA) {
// Formula should be adjusted // Formula should be adjusted
$pSheet->getCell($newCoordinates) $pSheet->getCell($newCoordinates)
->setValue($this->updateFormulaReferences($cell->getValue(), $pBefore, $pNumCols, $pNumRows, $pSheet->getTitle())); ->setValue($this->updateFormulaReferences($cell->getValue(),
$pBefore, $pNumCols, $pNumRows, $pSheet->getTitle()));
} else { } else {
// Formula should not be adjusted // Formula should not be adjusted
$pSheet->getCell($newCoordinates)->setValue($cell->getValue()); $pSheet->getCell($newCoordinates)->setValue($cell->getValue());
@ -145,6 +146,16 @@ class PHPExcel_ReferenceHelper
// Clear the original cell // Clear the original cell
$pSheet->getCell($cell->getCoordinate())->setValue(''); $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()));
}
} }
} }

View File

@ -220,7 +220,7 @@ class PHPExcel_Shared_Date
} // function isDateTimeFormat() } // function isDateTimeFormat()
private static $possibleDateFormatCharacters = 'ymdHis'; private static $possibleDateFormatCharacters = 'ymdHs';
/** /**
* Is a given number format code a date/time? * Is a given number format code a date/time?

View File

@ -64,7 +64,11 @@ Fixed in SVN:
- Bugfix: (MBaker) Reduced false positives from isDateTimeFormatCode() method by suppressing testing within quoted strings - 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 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 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. - General: (MBaker) Enhanced SheetViews element structures in the Excel2007 Writer for frozen panes.