Performance improvements
This commit is contained in:
parent
2296a48349
commit
98e5ac2b24
@ -1127,18 +1127,53 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
throw new PHPExcel_Exception('Cell coordinate can not be a range of cells.');
|
||||
} elseif (strpos($pCoordinate, '$') !== false) {
|
||||
throw new PHPExcel_Exception('Cell coordinate must not be absolute.');
|
||||
} else {
|
||||
}
|
||||
|
||||
// Create new cell object
|
||||
return $this->_createNewCell($pCoordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PHPExcel_Cell Cell that was found
|
||||
*/
|
||||
public function getCellByColumnAndRow($pColumn = 0, $pRow = 1)
|
||||
{
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
|
||||
$coordinate = $columnLetter . $pRow;
|
||||
|
||||
if ($this->_cellCollection->isDataSet($coordinate)) {
|
||||
return $this->_cellCollection->getCacheData($coordinate);
|
||||
}
|
||||
|
||||
return $this->_createNewCell($coordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new cell at the specified coordinate
|
||||
*
|
||||
* @param string $pCoordinate Coordinate of the cell
|
||||
* @return PHPExcel_Cell Cell that was created
|
||||
*/
|
||||
private function _createNewCell($pCoordinate)
|
||||
{
|
||||
$cell = $this->_cellCollection->addCacheData(
|
||||
$pCoordinate,
|
||||
new PHPExcel_Cell(
|
||||
NULL,
|
||||
PHPExcel_Cell_DataType::TYPE_NULL,
|
||||
$this
|
||||
)
|
||||
);
|
||||
$this->_cellCollectionIsSorted = false;
|
||||
|
||||
// Coordinates
|
||||
$aCoordinates = PHPExcel_Cell::coordinateFromString($pCoordinate);
|
||||
|
||||
$cell = $this->_cellCollection->addCacheData($pCoordinate,new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
||||
$this->_cellCollectionIsSorted = false;
|
||||
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < PHPExcel_Cell::columnIndexFromString($aCoordinates[0]))
|
||||
$this->_cachedHighestColumn = $aCoordinates[0];
|
||||
|
||||
$this->_cachedHighestRow = max($this->_cachedHighestRow, $aCoordinates[1]);
|
||||
|
||||
// Cell needs appropriate xfIndex
|
||||
@ -1155,34 +1190,6 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
||||
|
||||
return $cell;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 PHPExcel_Cell Cell that was found
|
||||
*/
|
||||
public function getCellByColumnAndRow($pColumn = 0, $pRow = 1)
|
||||
{
|
||||
$columnLetter = PHPExcel_Cell::stringFromColumnIndex($pColumn);
|
||||
$coordinate = $columnLetter . $pRow;
|
||||
|
||||
if (!$this->_cellCollection->isDataSet($coordinate)) {
|
||||
$cell = $this->_cellCollection->addCacheData($coordinate, new PHPExcel_Cell(NULL, PHPExcel_Cell_DataType::TYPE_NULL, $this));
|
||||
$this->_cellCollectionIsSorted = false;
|
||||
|
||||
if (PHPExcel_Cell::columnIndexFromString($this->_cachedHighestColumn) < $pColumn)
|
||||
$this->_cachedHighestColumn = $columnLetter;
|
||||
|
||||
$this->_cachedHighestRow = max($this->_cachedHighestRow,$pRow);
|
||||
|
||||
return $cell;
|
||||
}
|
||||
|
||||
return $this->_cellCollection->getCacheData($coordinate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell at a specific coordinate exists?
|
||||
|
Loading…
Reference in New Issue
Block a user