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

Source for file WorksheetIterator.php

Documentation is available at WorksheetIterator.php

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

Documentation generated on Sun, 27 Feb 2011 16:37:27 -0800 by phpDocumentor 1.4.3