ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
CellIterator.php
Go to the documentation of this file.
1 <?php
39 {
45  private $_subject;
46 
52  private $_rowIndex;
53 
59  private $_position = 0;
60 
66  private $_onlyExistingCells = true;
67 
74  public function __construct(PHPExcel_Worksheet $subject = null, $rowIndex = 1) {
75  // Set subject and row index
76  $this->_subject = $subject;
77  $this->_rowIndex = $rowIndex;
78  }
79 
83  public function __destruct() {
84  unset($this->_subject);
85  }
86 
90  public function rewind() {
91  $this->_position = 0;
92  }
93 
99  public function current() {
100  return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
101  }
102 
108  public function key() {
109  return $this->_position;
110  }
111 
115  public function next() {
117  }
118 
124  public function valid() {
125  // columnIndexFromString() returns an index based at one,
126  // treat it as a count when comparing it to the base zero
127  // position.
128  $columnCount = PHPExcel_Cell::columnIndexFromString($this->_subject->getHighestColumn());
129 
130  if ($this->_onlyExistingCells) {
131  // If we aren't looking at an existing cell, either
132  // because the first column doesn't exist or next() has
133  // been called onto a nonexistent cell, then loop until we
134  // find one, or pass the last column.
135  while ($this->_position < $columnCount &&
136  !$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
138  }
139  }
140 
141  return $this->_position < $columnCount;
142  }
143 
149  public function getIterateOnlyExistingCells() {
151  }
152 
158  public function setIterateOnlyExistingCells($value = true) {
159  $this->_onlyExistingCells = $value;
160  }
161 }