Bug in shared formulas: non-fixed cells are not updated if the formula has a fixed cell (#2354)
Example: right shift shared formula: IF(A$1=0,0,A1/A$1) Expected value: IF(B$1=0,0,B1/B$1) Actual value: IF(B$1=0,0,A1/B$1) Similar behavior is observed when copying formulas vertically. This issue occurs because a fixed and a non-fixed cell hit the same element of the $newCellTokens array by index $cellIndex
This commit is contained in:
parent
b1c9f0a1bc
commit
89edc5b267
|
|
@ -717,10 +717,12 @@ class ReferenceHelper
|
||||||
$toString = ($match[2] > '') ? $match[2] . '!' : '';
|
$toString = ($match[2] > '') ? $match[2] . '!' : '';
|
||||||
$toString .= $modified3;
|
$toString .= $modified3;
|
||||||
[$column, $row] = Coordinate::coordinateFromString($match[3]);
|
[$column, $row] = Coordinate::coordinateFromString($match[3]);
|
||||||
|
$columnAdditionalIndex = $column[0] === '$' ? 1 : 0;
|
||||||
|
$rowAdditionalIndex = $row[0] === '$' ? 1 : 0;
|
||||||
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
// Max worksheet size is 1,048,576 rows by 16,384 columns in Excel 2007, so our adjustments need to be at least one digit more
|
||||||
$column = Coordinate::columnIndexFromString(trim($column, '$')) + 100000;
|
$column = Coordinate::columnIndexFromString(trim($column, '$')) + 100000;
|
||||||
$row = (int) trim($row, '$') + 10000000;
|
$row = (int) trim($row, '$') + 10000000;
|
||||||
$cellIndex = $row . $column;
|
$cellIndex = $row . $rowAdditionalIndex . $column . $columnAdditionalIndex;
|
||||||
|
|
||||||
$newCellTokens[$cellIndex] = preg_quote($toString, '/');
|
$newCellTokens[$cellIndex] = preg_quote($toString, '/');
|
||||||
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])' . preg_quote($fromString, '/') . '(?!\d)/i';
|
$cellTokens[$cellIndex] = '/(?<![A-Z\$\!])' . preg_quote($fromString, '/') . '(?!\d)/i';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
[
|
||||||
|
'=IF(A$1=0,0,A1/A$1)',
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
'2021',
|
||||||
|
'=IF(B$1=0,0,B1/B$1)',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'=IF($A1=0,0,A1/$A1)',
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
'2021',
|
||||||
|
'=IF($A2=0,0,A2/$A2)',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'=SUM(C3:E5)',
|
'=SUM(C3:E5)',
|
||||||
-2,
|
-2,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue