You are here

public function PHPExcel_Worksheet::getCell in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php \PHPExcel_Worksheet::getCell()

Get cell at a specific coordinate

Parameters

string $pCoordinate Coordinate of the cell:

Return value

PHPExcel_Cell Cell that was found

Throws

PHPExcel_Exception

1 call to PHPExcel_Worksheet::getCell()
PHPExcel_Worksheet::calculateColumnWidths in vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php
Calculate widths for auto-size columns

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php, line 1153

Class

PHPExcel_Worksheet
PHPExcel_Worksheet

Code

public function getCell($pCoordinate = 'A1') {
  $pCoordinate = strtoupper($pCoordinate);

  // Check cell collection
  if ($this->_cellCollection
    ->isDataSet($pCoordinate)) {
    return $this->_cellCollection
      ->getCacheData($pCoordinate);
  }

  // Worksheet reference?
  if (strpos($pCoordinate, '!') !== false) {
    $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pCoordinate, true);
    return $this->_parent
      ->getSheetByName($worksheetReference[0])
      ->getCell($worksheetReference[1]);
  }

  // Named range?
  if (!preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches) && preg_match('/^' . PHPExcel_Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches)) {
    $namedRange = PHPExcel_NamedRange::resolveRange($pCoordinate, $this);
    if ($namedRange !== NULL) {
      $pCoordinate = $namedRange
        ->getRange();
      return $namedRange
        ->getWorksheet()
        ->getCell($pCoordinate);
    }
  }

  // Uppercase coordinate
  $pCoordinate = strtoupper($pCoordinate);
  if (strpos($pCoordinate, ':') !== false || strpos($pCoordinate, ',') !== false) {
    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.');
  }

  // Create new cell object
  return $this
    ->_createNewCell($pCoordinate);
}