Updated gui for user facility settings (#1327)
[openemr.git] / vendor / phpoffice / phpexcel / Classes / PHPExcel / Worksheet / RowIterator.php
blob110d8621437e8f6542c28dc4d265c85ab26f1fa5
1 <?php
2 /**
3 * PHPExcel
5 * Copyright (c) 2006 - 2014 PHPExcel
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * @category PHPExcel
22 * @package PHPExcel_Worksheet
23 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
24 * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25 * @version ##VERSION##, ##DATE##
29 /**
30 * PHPExcel_Worksheet_RowIterator
32 * Used to iterate rows in a PHPExcel_Worksheet
34 * @category PHPExcel
35 * @package PHPExcel_Worksheet
36 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
38 class PHPExcel_Worksheet_RowIterator implements Iterator
40 /**
41 * PHPExcel_Worksheet to iterate
43 * @var PHPExcel_Worksheet
45 private $_subject;
47 /**
48 * Current iterator position
50 * @var int
52 private $_position = 1;
54 /**
55 * Start position
57 * @var int
59 private $_startRow = 1;
62 /**
63 * End position
65 * @var int
67 private $_endRow = 1;
70 /**
71 * Create a new row iterator
73 * @param PHPExcel_Worksheet $subject The worksheet to iterate over
74 * @param integer $startRow The row number at which to start iterating
75 * @param integer $endRow Optionally, the row number at which to stop iterating
77 public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) {
78 // Set subject
79 $this->_subject = $subject;
80 $this->resetEnd($endRow);
81 $this->resetStart($startRow);
84 /**
85 * Destructor
87 public function __destruct() {
88 unset($this->_subject);
91 /**
92 * (Re)Set the start row and the current row pointer
94 * @param integer $startRow The row number at which to start iterating
95 * @return PHPExcel_Worksheet_RowIterator
97 public function resetStart($startRow = 1) {
98 $this->_startRow = $startRow;
99 $this->seek($startRow);
101 return $this;
105 * (Re)Set the end row
107 * @param integer $endRow The row number at which to stop iterating
108 * @return PHPExcel_Worksheet_RowIterator
110 public function resetEnd($endRow = null) {
111 $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
113 return $this;
117 * Set the row pointer to the selected row
119 * @param integer $row The row number to set the current pointer at
120 * @return PHPExcel_Worksheet_RowIterator
121 * @throws PHPExcel_Exception
123 public function seek($row = 1) {
124 if (($row < $this->_startRow) || ($row > $this->_endRow)) {
125 throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
127 $this->_position = $row;
129 return $this;
133 * Rewind the iterator to the starting row
135 public function rewind() {
136 $this->_position = $this->_startRow;
140 * Return the current row in this worksheet
142 * @return PHPExcel_Worksheet_Row
144 public function current() {
145 return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
149 * Return the current iterator key
151 * @return int
153 public function key() {
154 return $this->_position;
158 * Set the iterator to its next value
160 public function next() {
161 ++$this->_position;
165 * Set the iterator to its previous value
167 public function prev() {
168 if ($this->_position <= $this->_startRow) {
169 throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
172 --$this->_position;
176 * Indicate if more rows exist in the worksheet range of rows that we're iterating
178 * @return boolean
180 public function valid() {
181 return $this->_position <= $this->_endRow;