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
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 1.8.0, 2014-03-02
26: */
27:
28:
29: /**
30: * PHPExcel_WorksheetIterator
31: *
32: * Used to iterate worksheets in PHPExcel
33: *
34: * @category PHPExcel
35: * @package PHPExcel
36: * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
37: */
38: class PHPExcel_WorksheetIterator implements Iterator
39: {
40: /**
41: * Spreadsheet to iterate
42: *
43: * @var PHPExcel
44: */
45: private $_subject;
46:
47: /**
48: * Current iterator position
49: *
50: * @var int
51: */
52: private $_position = 0;
53:
54: /**
55: * Create a new worksheet iterator
56: *
57: * @param PHPExcel $subject
58: */
59: public function __construct(PHPExcel $subject = null)
60: {
61: // Set subject
62: $this->_subject = $subject;
63: }
64:
65: /**
66: * Destructor
67: */
68: public function __destruct()
69: {
70: unset($this->_subject);
71: }
72:
73: /**
74: * Rewind iterator
75: */
76: public function rewind()
77: {
78: $this->_position = 0;
79: }
80:
81: /**
82: * Current PHPExcel_Worksheet
83: *
84: * @return PHPExcel_Worksheet
85: */
86: public function current()
87: {
88: return $this->_subject->getSheet($this->_position);
89: }
90:
91: /**
92: * Current key
93: *
94: * @return int
95: */
96: public function key()
97: {
98: return $this->_position;
99: }
100:
101: /**
102: * Next value
103: */
104: public function next()
105: {
106: ++$this->_position;
107: }
108:
109: /**
110: * More PHPExcel_Worksheet instances available?
111: *
112: * @return boolean
113: */
114: public function valid()
115: {
116: return $this->_position < $this->_subject->getSheetCount();
117: }
118: }
119: