mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-22 13:26:07 +03:00
Bugfix: Work item 20397 - Serious bug in absolute cell reference used in shared formula
Would also have affected insert/delete column/row
This commit is contained in:
parent
f9f37f566a
commit
94a1a69373
@ -262,36 +262,34 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
||||
|
||||
|
||||
private function _castToFormula($c,$r,&$cellDataType,&$value,&$calculatedValue,&$sharedFormulas,$castBaseType) {
|
||||
// echo 'Formula<br />';
|
||||
// echo '$c->f is '.$c->f.'<br />';
|
||||
// echo 'Formula',PHP_EOL;
|
||||
// echo '$c->f is '.$c->f.PHP_EOL;
|
||||
$cellDataType = 'f';
|
||||
$value = "={$c->f}";
|
||||
$calculatedValue = self::$castBaseType($c);
|
||||
|
||||
// Shared formula?
|
||||
if (isset($c->f['t']) && strtolower((string)$c->f['t']) == 'shared') {
|
||||
// echo 'SHARED FORMULA<br />';
|
||||
// echo 'SHARED FORMULA'.PHP_EOL;
|
||||
$instance = (string)$c->f['si'];
|
||||
|
||||
// echo 'Instance ID = '.$instance.'<br />';
|
||||
// echo 'Instance ID = '.$instance.PHP_EOL;
|
||||
//
|
||||
// echo 'Shared Formula Array:<pre>';
|
||||
// echo 'Shared Formula Array:'.PHP_EOL;
|
||||
// print_r($sharedFormulas);
|
||||
// echo '</pre>';
|
||||
if (!isset($sharedFormulas[(string)$c->f['si']])) {
|
||||
// echo 'SETTING NEW SHARED FORMULA<br />';
|
||||
// echo 'Master is '.$r.'<br />';
|
||||
// echo 'Formula is '.$value.'<br />';
|
||||
// echo 'SETTING NEW SHARED FORMULA'.PHP_EOL;
|
||||
// echo 'Master is '.$r.PHP_EOL;
|
||||
// echo 'Formula is '.$value.PHP_EOL;
|
||||
$sharedFormulas[$instance] = array( 'master' => $r,
|
||||
'formula' => $value
|
||||
);
|
||||
// echo 'New Shared Formula Array:<pre>';
|
||||
// echo 'New Shared Formula Array:'.PHP_EOL;
|
||||
// print_r($sharedFormulas);
|
||||
// echo '</pre>';
|
||||
} else {
|
||||
// echo 'GETTING SHARED FORMULA<br />';
|
||||
// echo 'Master is '.$sharedFormulas[$instance]['master'].'<br />';
|
||||
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].'<br />';
|
||||
// echo 'GETTING SHARED FORMULA'.PHP_EOL;
|
||||
// echo 'Master is '.$sharedFormulas[$instance]['master'].PHP_EOL;
|
||||
// echo 'Formula is '.$sharedFormulas[$instance]['formula'].PHP_EOL;
|
||||
$master = PHPExcel_Cell::coordinateFromString($sharedFormulas[$instance]['master']);
|
||||
$current = PHPExcel_Cell::coordinateFromString($r);
|
||||
|
||||
@ -304,7 +302,7 @@ class PHPExcel_Reader_Excel2007 extends PHPExcel_Reader_Abstract implements PHPE
|
||||
$difference[0],
|
||||
$difference[1]
|
||||
);
|
||||
// echo 'Adjusted Formula is '.$value.'<br />';
|
||||
// echo 'Adjusted Formula is '.$value.PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -702,7 +702,7 @@ class PHPExcel_ReferenceHelper
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?![A-Z])/i';
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])'.preg_quote($fromString).'(?![A-Z])/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
@ -728,7 +728,7 @@ class PHPExcel_ReferenceHelper
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z]\$\!)'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
@ -740,8 +740,8 @@ class PHPExcel_ReferenceHelper
|
||||
foreach($matches as $match) {
|
||||
$fromString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
$fromString .= $match[3];
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
|
||||
$modified3 = $this->updateCellReference($match[3],$pBefore,$pNumCols,$pNumRows);
|
||||
if ($match[3] !== $modified3) {
|
||||
if (($match[2] == '') || (trim($match[2],"'") == $sheetName)) {
|
||||
$toString = ($match[2] > '') ? $match[2].'!' : '';
|
||||
@ -753,7 +753,7 @@ class PHPExcel_ReferenceHelper
|
||||
$cellIndex = $column.$row;
|
||||
|
||||
$newCellTokens[$cellIndex] = preg_quote($toString);
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z])'.preg_quote($fromString).'(?!\d)/i';
|
||||
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])'.preg_quote($fromString).'(?!\d)/i';
|
||||
++$adjustCount;
|
||||
}
|
||||
}
|
||||
@ -890,7 +890,6 @@ class PHPExcel_ReferenceHelper
|
||||
// Verify which parts should be updated
|
||||
$updateColumn = (($newColumn{0} != '$') && ($beforeColumn{0} != '$') &&
|
||||
PHPExcel_Cell::columnIndexFromString($newColumn) >= PHPExcel_Cell::columnIndexFromString($beforeColumn));
|
||||
|
||||
$updateRow = (($newRow{0} != '$') && ($beforeRow{0} != '$') &&
|
||||
$newRow >= $beforeRow);
|
||||
|
||||
|
@ -29,6 +29,8 @@ Fixed in develop branch for release v1.8.0:
|
||||
- Bugfix: (MBaker) - Style error with merged cells in PDF Writer
|
||||
- Bugfix: (MBaker) - Problem with cloning worksheets
|
||||
- Bugfix: (tavoarcila) Work Item GH-259 - Bug fix reading Open Office files
|
||||
- Bugfix: (MBaker) Work item 20397 - Serious bug in absolute cell reference used in shared formula
|
||||
Would also have affected insert/delete column/row
|
||||
- Feature: (amerov) - Implementation of the Excel HLOOKUP() function
|
||||
- Feature: (MBaker) - Added "Quote Prefix" to style settings (Excel2007 Reader and Writer only)
|
||||
- Feature: (MBaker) - Added Horizontal FILL alignment for Excel5 and Excel2007 Readers/Writers, and Horizontal DISTRIBUTED alignment for Excel2007 Reader/Writer
|
||||
|
Loading…
Reference in New Issue
Block a user