Allow deleting of columns beyond the end of data in a worksheet to update references (print area, etc) before early exiting the method

This commit is contained in:
MarkBaker 2022-03-13 18:10:28 +01:00
parent 092f90220e
commit a8d9cd700e
1 changed files with 6 additions and 6 deletions

View File

@ -2219,16 +2219,18 @@ class Worksheet implements IComparable
$highestColumnIndex = Coordinate::columnIndexFromString($highestColumn);
$pColumnIndex = Coordinate::columnIndexFromString($column);
if ($pColumnIndex > $highestColumnIndex) {
return $this;
}
$holdColumnDimensions = $this->removeColumnDimensions($pColumnIndex, $numberOfColumns);
$column = Coordinate::stringFromColumnIndex($pColumnIndex + $numberOfColumns);
$objReferenceHelper = ReferenceHelper::getInstance();
$objReferenceHelper->insertNewBefore($column . '1', -$numberOfColumns, 0, $this);
$this->columnDimensions = $holdColumnDimensions;
if ($pColumnIndex > $highestColumnIndex) {
return $this;
}
$maxPossibleColumnsToBeRemoved = $highestColumnIndex - $pColumnIndex + 1;
for ($c = 0, $n = min($maxPossibleColumnsToBeRemoved, $numberOfColumns); $c < $n; ++$c) {
@ -2236,8 +2238,6 @@ class Worksheet implements IComparable
$highestColumn = Coordinate::stringFromColumnIndex(Coordinate::columnIndexFromString($highestColumn) - 1);
}
$this->columnDimensions = $holdColumnDimensions;
$this->garbageCollect();
return $this;