Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Worksheet/PageSetup.php
public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE)
    {
        if (strpos($value, '!') !== false) {
            throw new PhpSpreadsheetException('Cell coordinate must not specify a worksheet.');
        } elseif (strpos($value, ':') === false) {
            throw new PhpSpreadsheetException('Cell coordinate must be a range of cells.');
        } elseif (strpos($value, '$') !== false) {
            throw new PhpSpreadsheetException('Cell coordinate must not be absolute.');
        }
        $value = strtoupper($value);

        if ($method == self::SETPRINTRANGE_OVERWRITE) {
            if ($index == 0) {
                $this->printArea = $value;
            } else {
                $printAreas = explode(',', $this->printArea);
                if ($index < 0) {
                    $index = count($printAreas) - abs($index) + 1;
                }
                if (($index <= 0) || ($index > count($printAreas))) {
                    throw new PhpSpreadsheetException('Invalid index for setting print range.');
                }
                $printAreas[$index - 1] = $value;
                $this->printArea = implode(',', $printAreas);
            }
        } elseif ($method == self::SETPRINTRANGE_INSERT) {
            if ($index == 0) {
                $this->printArea .= ($this->printArea == '') ? $value : ',' . $value;
            } else {
                $printAreas = explode(',', $this->printArea);
                if ($index < 0) {
                    $index = abs($index) - 1;
                }
                if ($index > count($printAreas)) {
                    throw new PhpSpreadsheetException('Invalid index for setting print range.');
                }
                $printAreas = array_merge(array_slice($printAreas, 0, $index), [$value], array_slice($printAreas, $index));
                $this->printArea = implode(',', $printAreas);
            }
        } else {
            throw new PhpSpreadsheetException('Invalid method for setting print range.');
        }

        return $this;
    }
public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE)
    {
        if (strpos($value, '!') !== false) {
            throw new PhpSpreadsheetException('Cell coordinate must not specify a worksheet.');
        } elseif (strpos($value, ':') === false) {
            throw new PhpSpreadsheetException('Cell coordinate must be a range of cells.');
        } elseif (strpos($value, '$') !== false) {
            throw new PhpSpreadsheetException('Cell coordinate must not be absolute.');
        }
        $value = strtoupper($value);

        if ($method == self::SETPRINTRANGE_OVERWRITE) {
            if ($index == 0) {
                $this->printArea = $value;
            } else {
                $printAreas = explode(',', $this->printArea);
                if ($index < 0) {
                    $index = count($printAreas) - abs($index) + 1;
                }
                if (($index <= 0) || ($index > count($printAreas))) {
                    throw new PhpSpreadsheetException('Invalid index for setting print range.');
                }
                $printAreas[$index - 1] = $value;
                $this->printArea = implode(',', $printAreas);
            }
        } elseif ($method == self::SETPRINTRANGE_INSERT) {
            if ($index == 0) {
                $this->printArea .= ($this->printArea == '') ? $value : ',' . $value;
            } else {
                $printAreas = explode(',', $this->printArea);
                if ($index < 0) {
                    $index = abs($index) - 1;
                }
                if ($index > count($printAreas)) {
                    throw new PhpSpreadsheetException('Invalid index for setting print range.');
                }
                $printAreas = array_merge(array_slice($printAreas, 0, $index), [$value], array_slice($printAreas, $index));
                $this->printArea = implode(',', $printAreas);
            }
        } else {
            throw new PhpSpreadsheetException('Invalid method for setting print range.');
        }

        return $this;
    }
public function setPrintArea ( $ value , $ index = 0 , $ method = self :: SETPRINTRANGE_OVERWRITE ) { if ( strpos ( $ value , '!' ) !== false ) { throw new PhpSpreadsheetException ( 'Cell coordinate must not specify a worksheet.' ) ; } elseif ( strpos ( $ value , ':' ) === false ) { throw new PhpSpreadsheetException ( 'Cell coordinate must be a range of cells.' ) ; } elseif ( strpos ( $ value , '$' ) !== false ) { throw new PhpSpreadsheetException ( 'Cell coordinate must not be absolute.' ) ; } $ value = strtoupper ( $ value ) ; if ( $ method == self :: SETPRINTRANGE_OVERWRITE ) { if ( $ index == 0 ) { $ this -> printArea = $ value ; } else { $ printAreas = explode ( ',' , $ this -> printArea ) ; if ( $ index < 0 ) { $ index = count ( $ printAreas ) - abs ( $ index ) + 1 ; } if ( ( $ index <= 0 ) || ( $ index > count ( $ printAreas ) ) ) { throw new PhpSpreadsheetException ( 'Invalid index for setting print range.' ) ; } $ printAreas [ $ index - 1 ] = $ value ; $ this -> printArea = implode ( ',' , $ printAreas ) ; } } elseif ( $ method == self :: SETPRINTRANGE_INSERT ) { if ( $ index == 0 ) { $ this -> printArea .= ( $ this -> printArea == '' ) ? $ value : ',' . $ value ; } else { $ printAreas = explode ( ',' , $ this -> printArea ) ; if ( $ index < 0 ) { $ index = abs ( $ index ) - 1 ; } if ( $ index > count ( $ printAreas ) ) { throw new PhpSpreadsheetException ( 'Invalid index for setting print range.' ) ; } $ printAreas = array_merge ( array_slice ( $ printAreas , 0 , $ index ) , [ $ value ] , array_slice ( $ printAreas , $ index ) ) ; $ this -> printArea = implode ( ',' , $ printAreas ) ; } } else { throw new PhpSpreadsheetException ( 'Invalid method for setting print range.' ) ; } return $ this ; }
Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20'.

@param string $value
@param int $index Identifier for a specific print area range allowing several ranges to be set
When the method is "O"verwrite, then a positive integer index will overwrite that indexed
entry in the print areas list; a negative index value will identify which entry to
overwrite working bacward through the print area to the list, with the last entry as -1.
Specifying an index value of 0, will overwrite <b>all</b> existing print ranges.
When the method is "I"nsert, then a positive index will insert after that indexed entry in
the print areas list, while a negative index will insert before the indexed entry.
Specifying an index value of 0, will always append the new print range at the end of the
list.
Print areas are numbered from 1
@param string $method Determines the method used when setting multiple print areas
Default behaviour, or the "O" method, overwrites existing print area
The "I" method, inserts the new print area before any specified index, or at the end of the list

@throws PhpSpreadsheetException

@return PageSetup
Set print area . e . g . A1 : D10 or A1 : D10 G5 : M20 .