Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/Worksheet.php
public function shrinkRangeToFit($range)
    {
        $maxCol = $this->getHighestColumn();
        $maxRow = $this->getHighestRow();
        $maxCol = Coordinate::columnIndexFromString($maxCol);

        $rangeBlocks = explode(' ', $range);
        foreach ($rangeBlocks as &$rangeSet) {
            $rangeBoundaries = Coordinate::getRangeBoundaries($rangeSet);

            if (Coordinate::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) {
                $rangeBoundaries[0][0] = Coordinate::stringFromColumnIndex($maxCol);
            }
            if ($rangeBoundaries[0][1] > $maxRow) {
                $rangeBoundaries[0][1] = $maxRow;
            }
            if (Coordinate::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) {
                $rangeBoundaries[1][0] = Coordinate::stringFromColumnIndex($maxCol);
            }
            if ($rangeBoundaries[1][1] > $maxRow) {
                $rangeBoundaries[1][1] = $maxRow;
            }
            $rangeSet = $rangeBoundaries[0][0] . $rangeBoundaries[0][1] . ':' . $rangeBoundaries[1][0] . $rangeBoundaries[1][1];
        }
        unset($rangeSet);
        $stRange = implode(' ', $rangeBlocks);

        return $stRange;
    }
public function shrinkRangeToFit($range)
    {
        $maxCol = $this->getHighestColumn();
        $maxRow = $this->getHighestRow();
        $maxCol = Coordinate::columnIndexFromString($maxCol);

        $rangeBlocks = explode(' ', $range);
        foreach ($rangeBlocks as &$rangeSet) {
            $rangeBoundaries = Coordinate::getRangeBoundaries($rangeSet);

            if (Coordinate::columnIndexFromString($rangeBoundaries[0][0]) > $maxCol) {
                $rangeBoundaries[0][0] = Coordinate::stringFromColumnIndex($maxCol);
            }
            if ($rangeBoundaries[0][1] > $maxRow) {
                $rangeBoundaries[0][1] = $maxRow;
            }
            if (Coordinate::columnIndexFromString($rangeBoundaries[1][0]) > $maxCol) {
                $rangeBoundaries[1][0] = Coordinate::stringFromColumnIndex($maxCol);
            }
            if ($rangeBoundaries[1][1] > $maxRow) {
                $rangeBoundaries[1][1] = $maxRow;
            }
            $rangeSet = $rangeBoundaries[0][0] . $rangeBoundaries[0][1] . ':' . $rangeBoundaries[1][0] . $rangeBoundaries[1][1];
        }
        unset($rangeSet);
        $stRange = implode(' ', $rangeBlocks);

        return $stRange;
    }
public function shrinkRangeToFit ( $ range ) { $ maxCol = $ this -> getHighestColumn ( ) ; $ maxRow = $ this -> getHighestRow ( ) ; $ maxCol = Coordinate :: columnIndexFromString ( $ maxCol ) ; $ rangeBlocks = explode ( ' ' , $ range ) ; foreach ( $ rangeBlocks as & $ rangeSet ) { $ rangeBoundaries = Coordinate :: getRangeBoundaries ( $ rangeSet ) ; if ( Coordinate :: columnIndexFromString ( $ rangeBoundaries [ 0 ] [ 0 ] ) > $ maxCol ) { $ rangeBoundaries [ 0 ] [ 0 ] = Coordinate :: stringFromColumnIndex ( $ maxCol ) ; } if ( $ rangeBoundaries [ 0 ] [ 1 ] > $ maxRow ) { $ rangeBoundaries [ 0 ] [ 1 ] = $ maxRow ; } if ( Coordinate :: columnIndexFromString ( $ rangeBoundaries [ 1 ] [ 0 ] ) > $ maxCol ) { $ rangeBoundaries [ 1 ] [ 0 ] = Coordinate :: stringFromColumnIndex ( $ maxCol ) ; } if ( $ rangeBoundaries [ 1 ] [ 1 ] > $ maxRow ) { $ rangeBoundaries [ 1 ] [ 1 ] = $ maxRow ; } $ rangeSet = $ rangeBoundaries [ 0 ] [ 0 ] . $ rangeBoundaries [ 0 ] [ 1 ] . ':' . $ rangeBoundaries [ 1 ] [ 0 ] . $ rangeBoundaries [ 1 ] [ 1 ] ; } unset ( $ rangeSet ) ; $ stRange = implode ( ' ' , $ rangeBlocks ) ; return $ stRange ; }
Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet.

@param string $range

@return string Adjusted range value
Accepts a range returning it as a range that falls within the current highest row and column of the worksheet .