e86e861aa9676ec28752778868407164ab74f75b.svn-base 2.6 KB

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