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 - 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
  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.  
  36. /**
  37.  * PHPExcel_WorksheetIterator
  38.  * 
  39.  * Used to iterate worksheets in PHPExcel
  40.  *
  41.  * @category   PHPExcel
  42.  * @package    PHPExcel
  43.  * @copyright  Copyright (c) 2006 - 2009 PHPExcel (http://www.codeplex.com/PHPExcel)
  44.  */
  45. class PHPExcel_WorksheetIterator extends IteratorIterator
  46. {
  47.     /**
  48.      * Spreadsheet to iterate
  49.      *
  50.      * @var PHPExcel 
  51.      */
  52.     private $_subject;
  53.     
  54.     /**
  55.      * Current iterator position
  56.      *
  57.      * @var int 
  58.      */
  59.     private $_position = 0;
  60.  
  61.     /**
  62.      * Create a new worksheet iterator
  63.      *
  64.      * @param PHPExcel         $subject 
  65.      */
  66.     public function __construct(PHPExcel $subject null{
  67.         // Set subject
  68.         $this->_subject = $subject;
  69.     }
  70.     
  71.     /**
  72.      * Destructor
  73.      */
  74.     public function __destruct({
  75.         unset($this->_subject);
  76.     }
  77.     
  78.     /**
  79.      * Rewind iterator
  80.      */
  81.     public function rewind({
  82.         $this->_position = 0;
  83.     }
  84.  
  85.     /**
  86.      * Current PHPExcel_Worksheet
  87.      *
  88.      * @return PHPExcel_Worksheet 
  89.      */
  90.     public function current({
  91.         return $this->_subject->getSheet($this->_position);
  92.     }
  93.  
  94.     /**
  95.      * Current key
  96.      *
  97.      * @return int 
  98.      */
  99.     public function key({
  100.         return $this->_position;
  101.     }
  102.  
  103.     /**
  104.      * Next value
  105.      */
  106.     public function next({
  107.         ++$this->_position;
  108.     }
  109.  
  110.     /**
  111.      * More PHPExcel_Worksheet instances available?
  112.      *
  113.      * @return boolean 
  114.      */
  115.     public function valid({
  116.         return $this->_position < $this->_subject->getSheetCount();
  117.     }
  118. }

Documentation generated on Wed, 22 Apr 2009 09:07:04 +0200 by phpDocumentor 1.4.1