Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2388 jpm 1
<?php
2
/**
3
 * PHPExcel
4
 *
5
 * Copyright (c) 2006 - 2013 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 - 2013 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 - 2013 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
	 * Create a new row iterator
64
	 *
65
	 * @param	PHPExcel_Worksheet	$subject	The worksheet to iterate over
66
	 * @param	integer				$startRow	The row number at which to start iterating
67
	 */
68
	public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1) {
69
		// Set subject
70
		$this->_subject = $subject;
71
		$this->resetStart($startRow);
72
	}
73
 
74
	/**
75
	 * Destructor
76
	 */
77
	public function __destruct() {
78
		unset($this->_subject);
79
	}
80
 
81
	/**
82
	 * (Re)Set the start row and the current row pointer
83
	 *
84
	 * @param integer	$startRow	The row number at which to start iterating
85
	 */
86
	public function resetStart($startRow = 1) {
87
		$this->_startRow = $startRow;
88
		$this->seek($startRow);
89
	}
90
 
91
	/**
92
	 * Set the row pointer to the selected row
93
	 *
94
	 * @param integer	$row	The row number to set the current pointer at
95
	 */
96
	public function seek($row = 1) {
97
		$this->_position = $row;
98
	}
99
 
100
	/**
101
	 * Rewind the iterator to the starting row
102
	 */
103
	public function rewind() {
104
		$this->_position = $this->_startRow;
105
	}
106
 
107
	/**
108
	 * Return the current row in this worksheet
109
	 *
110
	 * @return PHPExcel_Worksheet_Row
111
	 */
112
	public function current() {
113
		return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
114
	}
115
 
116
	/**
117
	 * Return the current iterator key
118
	 *
119
	 * @return int
120
	 */
121
	public function key() {
122
		return $this->_position;
123
	}
124
 
125
	/**
126
	 * Set the iterator to its next value
127
	 */
128
	public function next() {
129
		++$this->_position;
130
	}
131
 
132
	/**
133
	 * Set the iterator to its previous value
134
	 */
135
	public function prev() {
136
		if ($this->_position > 1)
137
			--$this->_position;
138
	}
139
 
140
	/**
141
	 * Indicate if more rows exist in the worksheet
142
	 *
143
	 * @return boolean
144
	 */
145
	public function valid() {
146
		return $this->_position <= $this->_subject->getHighestRow();
147
	}
148
}