예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 /**
  * Create a new cell at the specified coordinate
  *
  * @param string $pCoordinate    Coordinate of the cell
  * @return Cell Cell that was created
  */
 private function createNewCell($pCoordinate)
 {
     $cell = $this->cellCollection->addCacheData($pCoordinate, new Cell(null, Cell\DataType::TYPE_NULL, $this));
     $this->cellCollectionIsSorted = false;
     // Coordinates
     $aCoordinates = Cell::coordinateFromString($pCoordinate);
     if (Cell::columnIndexFromString($this->cachedHighestColumn) < Cell::columnIndexFromString($aCoordinates[0])) {
         $this->cachedHighestColumn = $aCoordinates[0];
     }
     $this->cachedHighestRow = max($this->cachedHighestRow, $aCoordinates[1]);
     // Cell needs appropriate xfIndex from dimensions records
     //    but don't create dimension records if they don't already exist
     $rowDimension = $this->getRowDimension($aCoordinates[1], false);
     $columnDimension = $this->getColumnDimension($aCoordinates[0], false);
     if ($rowDimension !== null && $rowDimension->getXfIndex() > 0) {
         // then there is a row dimension with explicit style, assign it to the cell
         $cell->setXfIndex($rowDimension->getXfIndex());
     } elseif ($columnDimension !== null && $columnDimension->getXfIndex() > 0) {
         // then there is a column dimension, assign it to the cell
         $cell->setXfIndex($columnDimension->getXfIndex());
     }
     return $cell;
 }