PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.0.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpexcel / Classes / PHPExcel / Worksheet / RowIterator.php

RowIterator.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.0.3, at vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet/RowIterator.php

184 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHPExcel
4 *
5 * Copyright (c) 2006 - 2014 PHPExcel
6 *
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.
11 *
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.
16 *
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
20 *
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##
26 */
27
28
29 /**
30 * PHPExcel_Worksheet_RowIterator
31 *
32 * Used to iterate rows in a PHPExcel_Worksheet
33 *
34 * @category PHPExcel
35 * @package PHPExcel_Worksheet
36 * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
37 */
38 class PHPExcel_Worksheet_RowIterator implements Iterator
39 {
40 /**
41 * PHPExcel_Worksheet to iterate
42 *
43 * @var PHPExcel_Worksheet
44 */
45 private $_subject;
46
47 /**
48 * Current iterator position
49 *
50 * @var int
51 */
52 private $_position = 1;
53
54 /**
55 * Start position
56 *
57 * @var int
58 */
59 private $_startRow = 1;
60
61
62 /**
63 * End position
64 *
65 * @var int
66 */
67 private $_endRow = 1;
68
69
70 /**
71 * Create a new row iterator
72 *
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
76 */
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);
82 }
83
84 /**
85 * Destructor
86 */
87 public function __destruct() {
88 unset($this->_subject);
89 }
90
91 /**
92 * (Re)Set the start row and the current row pointer
93 *
94 * @param integer $startRow The row number at which to start iterating
95 * @return PHPExcel_Worksheet_RowIterator
96 */
97 public function resetStart($startRow = 1) {
98 $this->_startRow = $startRow;
99 $this->seek($startRow);
100
101 return $this;
102 }
103
104 /**
105 * (Re)Set the end row
106 *
107 * @param integer $endRow The row number at which to stop iterating
108 * @return PHPExcel_Worksheet_RowIterator
109 */
110 public function resetEnd($endRow = null) {
111 $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
112
113 return $this;
114 }
115
116 /**
117 * Set the row pointer to the selected row
118 *
119 * @param integer $row The row number to set the current pointer at
120 * @return PHPExcel_Worksheet_RowIterator
121 * @throws PHPExcel_Exception
122 */
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})");
126 }
127 $this->_position = $row;
128
129 return $this;
130 }
131
132 /**
133 * Rewind the iterator to the starting row
134 */
135 public function rewind() {
136 $this->_position = $this->_startRow;
137 }
138
139 /**
140 * Return the current row in this worksheet
141 *
142 * @return PHPExcel_Worksheet_Row
143 */
144 public function current() {
145 return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
146 }
147
148 /**
149 * Return the current iterator key
150 *
151 * @return int
152 */
153 public function key() {
154 return $this->_position;
155 }
156
157 /**
158 * Set the iterator to its next value
159 */
160 public function next() {
161 ++$this->_position;
162 }
163
164 /**
165 * Set the iterator to its previous value
166 */
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})");
170 }
171
172 --$this->_position;
173 }
174
175 /**
176 * Indicate if more rows exist in the worksheet range of rows that we're iterating
177 *
178 * @return boolean
179 */
180 public function valid() {
181 return $this->_position <= $this->_endRow;
182 }
183 }
184