ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
NamedRange.php
Go to the documentation of this file.
1 <?php
37 {
43  private $_name;
44 
50  private $_worksheet;
51 
57  private $_range;
58 
64  private $_localOnly;
65 
71  private $_scope;
72 
83  public function __construct($pName = null, PHPExcel_Worksheet $pWorksheet, $pRange = 'A1', $pLocalOnly = false, $pScope = null)
84  {
85  // Validate data
86  if (($pName === NULL) || ($pWorksheet === NULL) || ($pRange === NULL)) {
87  throw new PHPExcel_Exception('Parameters can not be null.');
88  }
89 
90  // Set local members
91  $this->_name = $pName;
92  $this->_worksheet = $pWorksheet;
93  $this->_range = $pRange;
94  $this->_localOnly = $pLocalOnly;
95  $this->_scope = ($pLocalOnly == true) ?
96  (($pScope == null) ? $pWorksheet : $pScope) : null;
97  }
98 
104  public function getName() {
105  return $this->_name;
106  }
107 
114  public function setName($value = null) {
115  if ($value !== NULL) {
116  // Old title
117  $oldTitle = $this->_name;
118 
119  // Re-attach
120  if ($this->_worksheet !== NULL) {
121  $this->_worksheet->getParent()->removeNamedRange($this->_name,$this->_worksheet);
122  }
123  $this->_name = $value;
124 
125  if ($this->_worksheet !== NULL) {
126  $this->_worksheet->getParent()->addNamedRange($this);
127  }
128 
129  // New title
130  $newTitle = $this->_name;
131  PHPExcel_ReferenceHelper::getInstance()->updateNamedFormulas($this->_worksheet->getParent(), $oldTitle, $newTitle);
132  }
133  return $this;
134  }
135 
141  public function getWorksheet() {
142  return $this->_worksheet;
143  }
144 
151  public function setWorksheet(PHPExcel_Worksheet $value = null) {
152  if ($value !== NULL) {
153  $this->_worksheet = $value;
154  }
155  return $this;
156  }
157 
163  public function getRange() {
164  return $this->_range;
165  }
166 
173  public function setRange($value = null) {
174  if ($value !== NULL) {
175  $this->_range = $value;
176  }
177  return $this;
178  }
179 
185  public function getLocalOnly() {
186  return $this->_localOnly;
187  }
188 
195  public function setLocalOnly($value = false) {
196  $this->_localOnly = $value;
197  $this->_scope = $value ? $this->_worksheet : null;
198  return $this;
199  }
200 
206  public function getScope() {
207  return $this->_scope;
208  }
209 
216  public function setScope(PHPExcel_Worksheet $value = null) {
217  $this->_scope = $value;
218  $this->_localOnly = ($value == null) ? false : true;
219  return $this;
220  }
221 
229  public static function resolveRange($pNamedRange = '', PHPExcel_Worksheet $pSheet) {
230  return $pSheet->getParent()->getNamedRange($pNamedRange, $pSheet);
231  }
232 
236  public function __clone() {
237  $vars = get_object_vars($this);
238  foreach ($vars as $key => $value) {
239  if (is_object($value)) {
240  $this->$key = clone $value;
241  } else {
242  $this->$key = $value;
243  }
244  }
245  }
246 }
__construct($pName=null, PHPExcel_Worksheet $pWorksheet, $pRange='A1', $pLocalOnly=false, $pScope=null)
Create a new NamedRange.
Definition: NamedRange.php:83
static getInstance()
Get an instance of this class.
__clone()
Implement PHP __clone to create a deep clone, not just a shallow copy.
Definition: NamedRange.php:236
setScope(PHPExcel_Worksheet $value=null)
Set scope.
Definition: NamedRange.php:216
static resolveRange($pNamedRange='', PHPExcel_Worksheet $pSheet)
Resolve a named range to a regular cell range.
Definition: NamedRange.php:229
setWorksheet(PHPExcel_Worksheet $value=null)
Set worksheet.
Definition: NamedRange.php:151
getName()
Get name.
Definition: NamedRange.php:104
setRange($value=null)
Set range.
Definition: NamedRange.php:173
getParent()
Get parent.
Definition: Worksheet.php:786
getScope()
Get scope.
Definition: NamedRange.php:206
setLocalOnly($value=false)
Set localOnly.
Definition: NamedRange.php:195
getLocalOnly()
Get localOnly.
Definition: NamedRange.php:185
setName($value=null)
Set name.
Definition: NamedRange.php:114
getRange()
Get range.
Definition: NamedRange.php:163
$key
Definition: croninfo.php:18
getWorksheet()
Get worksheet.
Definition: NamedRange.php:141