Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php
public function getCell($pCoordinate, $createIfNotExists = true)
    {
        // Check cell collection
        if ($this->cellCollection->has(strtoupper($pCoordinate))) {
            return $this->cellCollection->get($pCoordinate);
        }

        // Worksheet reference?
        if (strpos($pCoordinate, '!') !== false) {
            $worksheetReference = self::extractSheetTitle($pCoordinate, true);

            return $this->parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]), $createIfNotExists);
        }

        // Named range?
        if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) &&
            (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) {
            $namedRange = NamedRange::resolveRange($pCoordinate, $this);
            if ($namedRange !== null) {
                $pCoordinate = $namedRange->getRange();

                return $namedRange->getWorksheet()->getCell($pCoordinate, $createIfNotExists);
            }
        }

        // Uppercase coordinate
        $pCoordinate = strtoupper($pCoordinate);

        if (Coordinate::coordinateIsRange($pCoordinate)) {
            throw new Exception('Cell coordinate can not be a range of cells.');
        } elseif (strpos($pCoordinate, '$') !== false) {
            throw new Exception('Cell coordinate must not be absolute.');
        }

        // Create new cell object, if required
        return $createIfNotExists ? $this->createNewCell($pCoordinate) : null;
    }
public function getCell($pCoordinate, $createIfNotExists = true)
    {
        // Check cell collection
        if ($this->cellCollection->has(strtoupper($pCoordinate))) {
            return $this->cellCollection->get($pCoordinate);
        }

        // Worksheet reference?
        if (strpos($pCoordinate, '!') !== false) {
            $worksheetReference = self::extractSheetTitle($pCoordinate, true);

            return $this->parent->getSheetByName($worksheetReference[0])->getCell(strtoupper($worksheetReference[1]), $createIfNotExists);
        }

        // Named range?
        if ((!preg_match('/^' . Calculation::CALCULATION_REGEXP_CELLREF . '$/i', $pCoordinate, $matches)) &&
            (preg_match('/^' . Calculation::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $pCoordinate, $matches))) {
            $namedRange = NamedRange::resolveRange($pCoordinate, $this);
            if ($namedRange !== null) {
                $pCoordinate = $namedRange->getRange();

                return $namedRange->getWorksheet()->getCell($pCoordinate, $createIfNotExists);
            }
        }

        // Uppercase coordinate
        $pCoordinate = strtoupper($pCoordinate);

        if (Coordinate::coordinateIsRange($pCoordinate)) {
            throw new Exception('Cell coordinate can not be a range of cells.');
        } elseif (strpos($pCoordinate, '$') !== false) {
            throw new Exception('Cell coordinate must not be absolute.');
        }

        // Create new cell object, if required
        return $createIfNotExists ? $this->createNewCell($pCoordinate) : null;
    }
public function getCell ( $ pCoordinate , $ createIfNotExists = true ) { // Check cell collection if ( $ this -> cellCollection -> has ( strtoupper ( $ pCoordinate ) ) ) { return $ this -> cellCollection -> get ( $ pCoordinate ) ; } // Worksheet reference? if ( strpos ( $ pCoordinate , '!' ) !== false ) { $ worksheetReference = self :: extractSheetTitle ( $ pCoordinate , true ) ; return $ this -> parent -> getSheetByName ( $ worksheetReference [ 0 ] ) -> getCell ( strtoupper ( $ worksheetReference [ 1 ] ) , $ createIfNotExists ) ; } // Named range? if ( ( ! preg_match ( '/^' . Calculation :: CALCULATION_REGEXP_CELLREF . '$/i' , $ pCoordinate , $ matches ) ) && ( preg_match ( '/^' . Calculation :: CALCULATION_REGEXP_NAMEDRANGE . '$/i' , $ pCoordinate , $ matches ) ) ) { $ namedRange = NamedRange :: resolveRange ( $ pCoordinate , $ this ) ; if ( $ namedRange !== null ) { $ pCoordinate = $ namedRange -> getRange ( ) ; return $ namedRange -> getWorksheet ( ) -> getCell ( $ pCoordinate , $ createIfNotExists ) ; } } // Uppercase coordinate $ pCoordinate = strtoupper ( $ pCoordinate ) ; if ( Coordinate :: coordinateIsRange ( $ pCoordinate ) ) { throw new Exception ( 'Cell coordinate can not be a range of cells.' ) ; } elseif ( strpos ( $ pCoordinate , '$' ) !== false ) { throw new Exception ( 'Cell coordinate must not be absolute.' ) ; } // Create new cell object, if required return $ createIfNotExists ? $ this -> createNewCell ( $ pCoordinate ) : null ; }
Get cell at a specific coordinate.

@param string $pCoordinate Coordinate of the cell, eg: 'A1'
@param bool $createIfNotExists Flag indicating whether a new cell should be created if it doesn't
already exist, or a null should be returned instead

@throws Exception

@return null|Cell Cell that was found/created or null
Get cell at a specific coordinate .