123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- class PHPExcel_Worksheet_RowIterator implements Iterator
- {
-
- private $_subject;
-
- private $_position = 1;
-
- private $_startRow = 1;
-
- private $_endRow = 1;
-
- public function __construct(PHPExcel_Worksheet $subject = null, $startRow = 1, $endRow = null) {
-
- $this->_subject = $subject;
- $this->resetEnd($endRow);
- $this->resetStart($startRow);
- }
-
- public function __destruct() {
- unset($this->_subject);
- }
-
- public function resetStart($startRow = 1) {
- $this->_startRow = $startRow;
- $this->seek($startRow);
- return $this;
- }
-
- public function resetEnd($endRow = null) {
- $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
- return $this;
- }
-
- public function seek($row = 1) {
- if (($row < $this->_startRow) || ($row > $this->_endRow)) {
- throw new PHPExcel_Exception("Row $row is out of range ({$this->_startRow} - {$this->_endRow})");
- }
- $this->_position = $row;
- return $this;
- }
-
- public function rewind() {
- $this->_position = $this->_startRow;
- }
-
- public function current() {
- return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
- }
-
- public function key() {
- return $this->_position;
- }
-
- public function next() {
- ++$this->_position;
- }
-
- public function prev() {
- if ($this->_position <= $this->_startRow) {
- throw new PHPExcel_Exception("Row is already at the beginning of range ({$this->_startRow} - {$this->_endRow})");
- }
- --$this->_position;
- }
-
- public function valid() {
- return $this->_position <= $this->_endRow;
- }
- }
|