You are here

public function PHPExcel_Worksheet_PageSetup::setPrintArea in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/PageSetup.php \PHPExcel_Worksheet_PageSetup::setPrintArea()

* Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20' * *

Parameters

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 * @return PHPExcel_Worksheet_PageSetup * @throws PHPExcel_Exception

3 calls to PHPExcel_Worksheet_PageSetup::setPrintArea()
PHPExcel_Worksheet_PageSetup::addPrintArea in vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/PageSetup.php
* Add a new print area (e.g. 'A1:D10' or 'A1:D10,G5:M20') to the list of print areas * *
PHPExcel_Worksheet_PageSetup::addPrintAreaByColumnAndRow in vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/PageSetup.php
* Add a new print area to the list of print areas * *
PHPExcel_Worksheet_PageSetup::setPrintAreaByColumnAndRow in vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/PageSetup.php
* Set print area * *

File

vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/PageSetup.php, line 645

Class

PHPExcel_Worksheet_PageSetup
PHPExcel_Worksheet_PageSetup

Code

public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) {
  if (strpos($value, '!') !== false) {
    throw new PHPExcel_Exception('Cell coordinate must not specify a worksheet.');
  }
  elseif (strpos($value, ':') === false) {
    throw new PHPExcel_Exception('Cell coordinate must be a range of cells.');
  }
  elseif (strpos($value, '$') !== false) {
    throw new PHPExcel_Exception('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 PHPExcel_Exception('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 PHPExcel_Exception('Invalid index for setting print range.');
      }
      $printAreas = array_merge(array_slice($printAreas, 0, $index), array(
        $value,
      ), array_slice($printAreas, $index));
      $this->_printArea = implode(',', $printAreas);
    }
  }
  else {
    throw new PHPExcel_Exception('Invalid method for setting print range.');
  }
  return $this;
}