CellIterator.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * PHPExcel_Worksheet_CellIterator
  4. *
  5. * Copyright (c) 2006 - 2015 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 - 2015 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. abstract class PHPExcel_Worksheet_CellIterator
  28. {
  29. /**
  30. * PHPExcel_Worksheet to iterate
  31. *
  32. * @var PHPExcel_Worksheet
  33. */
  34. protected $subject;
  35. /**
  36. * Current iterator position
  37. *
  38. * @var mixed
  39. */
  40. protected $position = null;
  41. /**
  42. * Iterate only existing cells
  43. *
  44. * @var boolean
  45. */
  46. protected $onlyExistingCells = false;
  47. /**
  48. * Destructor
  49. */
  50. public function __destruct()
  51. {
  52. unset($this->subject);
  53. }
  54. /**
  55. * Get loop only existing cells
  56. *
  57. * @return boolean
  58. */
  59. public function getIterateOnlyExistingCells()
  60. {
  61. return $this->onlyExistingCells;
  62. }
  63. /**
  64. * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary
  65. *
  66. * @throws PHPExcel_Exception
  67. */
  68. abstract protected function adjustForExistingOnlyRange();
  69. /**
  70. * Set the iterator to loop only existing cells
  71. *
  72. * @param boolean $value
  73. * @throws PHPExcel_Exception
  74. */
  75. public function setIterateOnlyExistingCells($value = true)
  76. {
  77. $this->onlyExistingCells = (boolean) $value;
  78. $this->adjustForExistingOnlyRange();
  79. }
  80. }