Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Worksheet;
   4  
   5  use Iterator;
   6  
   7  abstract class CellIterator implements Iterator
   8  {
   9      /**
  10       * Worksheet to iterate.
  11       *
  12       * @var Worksheet
  13       */
  14      protected $worksheet;
  15  
  16      /**
  17       * Iterate only existing cells.
  18       *
  19       * @var bool
  20       */
  21      protected $onlyExistingCells = false;
  22  
  23      /**
  24       * Destructor.
  25       */
  26      public function __destruct()
  27      {
  28          $this->worksheet = null;
  29      }
  30  
  31      /**
  32       * Get loop only existing cells.
  33       *
  34       * @return bool
  35       */
  36      public function getIterateOnlyExistingCells()
  37      {
  38          return $this->onlyExistingCells;
  39      }
  40  
  41      /**
  42       * Validate start/end values for "IterateOnlyExistingCells" mode, and adjust if necessary.
  43       */
  44      abstract protected function adjustForExistingOnlyRange();
  45  
  46      /**
  47       * Set the iterator to loop only existing cells.
  48       *
  49       * @param bool $value
  50       */
  51      public function setIterateOnlyExistingCells($value): void
  52      {
  53          $this->onlyExistingCells = (bool) $value;
  54  
  55          $this->adjustForExistingOnlyRange();
  56      }
  57  }