PHPExcel: How to delete a line to edit $ worksheet-> getHighestDataRow?

How to delete a row or row count in PHPExcel (1.7.7) so that getHighestDataRow decreases?

Using removeRow () does not seem to actually adjust the value of getHighestDataRow.

+4
source share
2 answers

That's right, it is not. You will notice that the same applies to columns.

Either do it yourself, or ask the authors of the library to fix this error in PHPExcel. It is known, but low in the list of priorities, so a further request to fix it may increase its list.

For an existing work item, see " Tracking for empty lines remains after removeRow () ." The described problem is more specific, but the reason is the same.

+2
source

FWIW, I believe this is now fixed. I am using PhpExcel 1.8, and the code for removeRow explicitly changes the value of maximumDataRow, namely:

public function removeRow($pRow = 1, $pNumRows = 1) { if ($pRow >= 1) { $highestRow = $this->getHighestDataRow(); $objReferenceHelper = PHPExcel_ReferenceHelper::getInstance(); $objReferenceHelper->insertNewBefore('A' . ($pRow + $pNumRows), 0, -$pNumRows, $this); for ($r = 0; $r < $pNumRows; ++$r) { $this->getCellCacheController()->removeRow($highestRow); --$highestRow; } } else { throw new PHPExcel_Exception("Rows to be deleted should at least start from row 1."); } return $this; } 

So, if this is still a problem for everyone, updating your version of PhpExcel should solve it.

0
source

Source: https://habr.com/ru/post/1436532/


All Articles