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

Documentation generated on Mon, 10 Aug 2009 08:07:41 +0200 by phpDocumentor 1.4.1