ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RowIterator.php
Go to the documentation of this file.
1 <?php
39 {
45  private $_subject;
46 
52  private $_position = 1;
53 
59  private $_startRow = 1;
60 
61 
67  private $_endRow = 1;
68 
69 
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 
87  public function __destruct() {
88  unset($this->_subject);
89  }
90 
97  public function resetStart($startRow = 1) {
98  $this->_startRow = $startRow;
99  $this->seek($startRow);
100 
101  return $this;
102  }
103 
110  public function resetEnd($endRow = null) {
111  $this->_endRow = ($endRow) ? $endRow : $this->_subject->getHighestRow();
112 
113  return $this;
114  }
115 
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 
135  public function rewind() {
136  $this->_position = $this->_startRow;
137  }
138 
144  public function current() {
145  return new PHPExcel_Worksheet_Row($this->_subject, $this->_position);
146  }
147 
153  public function key() {
154  return $this->_position;
155  }
156 
160  public function next() {
162  }
163 
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 
173  }
174 
180  public function valid() {
181  return $this->_position <= $this->_endRow;
182  }
183 }
resetEnd($endRow=null)
(Re)Set the end row
rewind()
Rewind the iterator to the starting row.
resetStart($startRow=1)
(Re)Set the start row and the current row pointer
Definition: RowIterator.php:97
valid()
Indicate if more rows exist in the worksheet range of rows that we&#39;re iterating.
prev()
Set the iterator to its previous value.
__construct(PHPExcel_Worksheet $subject=null, $startRow=1, $endRow=null)
Create a new row iterator.
Definition: RowIterator.php:77
key()
Return the current iterator key.
current()
Return the current row in this worksheet.
seek($row=1)
Set the row pointer to the selected row.
next()
Set the iterator to its next value.