/**
  * Are there any more PHPExcel_Cell instances available?
  *
  * @return boolean
  */
 public function valid()
 {
     // columnIndexFromString() returns an index based at one,
     // treat it as a count when comparing it to the base zero
     // position.
     $columnCount = PHPExcel_Cell::columnIndexFromString($this->_subject->getHighestColumn());
     if ($this->_onlyExistingCells) {
         // If we aren't looking at an existing cell, either
         // because the first column doesn't exist or next() has
         // been called onto a nonexistent cell, then loop until we
         // find one, or pass the last column.
         while ($this->_position < $columnCount && !$this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
             ++$this->_position;
         }
     }
     return $this->_position < $columnCount;
 }
Example #2
0
 /**
  * Current PHPExcel_Cell
  *
  * @return PHPExcel_Cell
  */
 public function current()
 {
     $cellExists = $this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex);
     if ($this->_onlyExistingCells && $cellExists || !$this->_onlyExistingCells) {
         return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
     } else {
         if ($this->_onlyExistingCells && !$cellExists) {
             // Loop untill we find one
             while ($this->valid()) {
                 $this->next();
                 if ($this->_subject->cellExistsByColumnAndRow($this->_position, $this->_rowIndex)) {
                     return $this->_subject->getCellByColumnAndRow($this->_position, $this->_rowIndex);
                 }
             }
         }
     }
     return null;
 }