PHPExcel_Worksheet
[ class tree: PHPExcel_Worksheet ] [ index: PHPExcel_Worksheet ] [ all elements ]

Source for file RowIterator.php

Documentation is available at RowIterator.php

  1. <?php
  2. /**
  3.  * PHPExcel
  4.  *
  5.  * Copyright (c) 2006 - 2009 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_Worksheet
  23.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  24.  * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  25.  * @version    1.6.7, 2009-04-22
  26.  */
  27.  
  28.  
  29. /** PHPExcel */
  30. require_once 'PHPExcel.php';
  31.  
  32. /** PHPExcel_Worksheet */
  33. require_once 'PHPExcel/Worksheet.php';
  34.  
  35. /** PHPExcel_Worksheet_Row */
  36. require_once 'PHPExcel/Worksheet/Row.php';
  37.  
  38.  
  39. /**
  40.  * PHPExcel_Worksheet_RowIterator
  41.  * 
  42.  * Used to iterate rows in a PHPExcel_Worksheet
  43.  *
  44.  * @category   PHPExcel
  45.  * @package    PHPExcel_Worksheet
  46.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  47.  */
  48. class PHPExcel_Worksheet_RowIterator extends IteratorIterator
  49. {
  50.     /**
  51.      * PHPExcel_Worksheet to iterate
  52.      *
  53.      * @var PHPExcel_Worksheet 
  54.      */
  55.     private $_subject;
  56.     
  57.     /**
  58.      * Current iterator position
  59.      *
  60.      * @var int 
  61.      */
  62.     private $_position = 0;
  63.  
  64.     /**
  65.      * Create a new row iterator
  66.      *
  67.      * @param PHPExcel_Worksheet         $subject 
  68.      */
  69.     public function __construct(PHPExcel_Worksheet $subject null{
  70.         // Set subject
  71.         $this->_subject = $subject;
  72.     }
  73.     
  74.     /**
  75.      * Destructor
  76.      */
  77.     public function __destruct({
  78.         unset($this->_subject);
  79.     }
  80.     
  81.     /**
  82.      * Rewind iterator
  83.      */
  84.     public function rewind({
  85.         $this->_position = 1;
  86.     }
  87.  
  88.     /**
  89.      * Current PHPExcel_Worksheet_Row
  90.      *
  91.      * @return PHPExcel_Worksheet_Row 
  92.      */
  93.     public function current({
  94.         return new PHPExcel_Worksheet_Row($this->_subject$this->_position);
  95.     }
  96.  
  97.     /**
  98.      * Current key
  99.      *
  100.      * @return int 
  101.      */
  102.     public function key({
  103.         return $this->_position;
  104.     }
  105.  
  106.     /**
  107.      * Next value
  108.      */
  109.     public function next({
  110.         ++$this->_position;
  111.     }
  112.  
  113.     /**
  114.      * More PHPExcel_Worksheet_Row instances available?
  115.      *
  116.      * @return boolean 
  117.      */
  118.     public function valid({
  119.         return $this->_position <= $this->_subject->getHighestRow();
  120.     }
  121. }

Documentation generated on Wed, 22 Apr 2009 09:01:53 +0200 by phpDocumentor 1.4.1