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

Documentation generated on Mon, 10 Aug 2009 08:12:00 +0200 by phpDocumentor 1.4.1