/** * Run PHPExcel garabage collector. * * @return Worksheet */ public function garbageCollect() { // Flush cache $this->cellCollection->getCacheData('A1'); // Build a reference table from images // $imageCoordinates = array(); // $iterator = $this->getDrawingCollection()->getIterator(); // while ($iterator->valid()) { // $imageCoordinates[$iterator->current()->getCoordinates()] = true; // // $iterator->next(); // } // // Lookup highest column and highest row if cells are cleaned $colRow = $this->cellCollection->getHighestRowAndColumn(); $highestRow = $colRow['row']; $highestColumn = Cell::columnIndexFromString($colRow['column']); // Loop through column dimensions foreach ($this->columnDimensions as $dimension) { $highestColumn = max($highestColumn, Cell::columnIndexFromString($dimension->getColumnIndex())); } // Loop through row dimensions foreach ($this->rowDimensions as $dimension) { $highestRow = max($highestRow, $dimension->getRowIndex()); } // Cache values if ($highestColumn < 0) { $this->cachedHighestColumn = 'A'; } else { $this->cachedHighestColumn = Cell::stringFromColumnIndex(--$highestColumn); } $this->cachedHighestRow = $highestRow; // Return return $this; }
/** * Get cell at a specific coordinate by using numeric cell coordinates * * @param string $pColumn Numeric column coordinate of the cell * @param string $pRow Numeric row coordinate of the cell * @return Cell Cell that was found */ public function getCellByColumnAndRow($pColumn = 0, $pRow = 0) { $columnLetter = Cell::stringFromColumnIndex($pColumn); $coordinate = $columnLetter . $pRow; if (!$this->_cellCollection->isDataSet($coordinate)) { $cell = $this->_cellCollection->addCacheData($coordinate, new Cell($columnLetter, $pRow, null, Cell_DataType::TYPE_NULL, $this)); $this->_cellCollectionIsSorted = false; if (Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn) { $this->_cachedHighestColumn = $columnLetter; } if ($this->_cachedHighestRow < $pRow) { $this->_cachedHighestRow = $pRow; } return $cell; } return $this->_cellCollection->getCacheData($coordinate); }