Source for file NamedRange.php
Documentation is available at NamedRange.php
* Copyright (c) 2006 - 2011 PHPExcel
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version 1.7.6, 2011-02-27
* @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
* Worksheet on which the named range can be resolved
* @var PHPExcel_Worksheet
* Range of the referenced cells
* Is the named range local? (i.e. can only be used on $this->_worksheet)
* @var PHPExcel_Worksheet
* Create a new NamedRange
* @param PHPExcel_Worksheet $pWorksheet
* @param bool $pLocalOnly
* @param PHPExcel_Worksheet|null$pScope Scope. Only applies when $pLocalOnly = true. Null for global scope.
public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
throw new Exception('Parameters can not be null.');
$this->_worksheet = $pWorksheet;
$this->_localOnly = $pLocalOnly;
$this->_scope = ($pLocalOnly == true) ?
(($pScope == null) ? $pWorksheet : $pScope) : null;
* @return PHPExcel_NamedRange
public function setName($value = null) {
$oldTitle = $this->_name;
$this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
$this->_worksheet->getParent()->addNamedRange($this);
$newTitle = $this->_name;
* @return PHPExcel_Worksheet
return $this->_worksheet;
* @param PHPExcel_Worksheet $value
* @return PHPExcel_NamedRange
public function setWorksheet(PHPExcel_Worksheet $value = null) {
$this->_worksheet = $value;
* @return PHPExcel_NamedRange
public function setRange($value = null) {
return $this->_localOnly;
* @return PHPExcel_NamedRange
$this->_localOnly = $value;
$this->_scope = $value ? $this->_worksheet : null;
* @return PHPExcel_Worksheet|null
* @param PHPExcel_Worksheet|null$value
* @return PHPExcel_NamedRange
public function setScope(PHPExcel_Worksheet $value = null) {
$this->_localOnly = ($value == null) ? false : true;
* Resolve a named range to a regular cell range
* @param string $pNamedRange Named range
* @param PHPExcel_Worksheet|null$pSheet Scope. Use null for global scope
* @return PHPExcel_NamedRange
public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
* Implement PHP __clone to create a deep clone, not just a shallow copy.
foreach ($vars as $key => $value) {
$this->$key = clone $value;
|