Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Worksheet;
   4  
   5  class Column
   6  {
   7      /**
   8       * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet.
   9       *
  10       * @var Worksheet
  11       */
  12      private $parent;
  13  
  14      /**
  15       * Column index.
  16       *
  17       * @var string
  18       */
  19      private $columnIndex;
  20  
  21      /**
  22       * Create a new column.
  23       *
  24       * @param Worksheet $parent
  25       * @param string $columnIndex
  26       */
  27      public function __construct(Worksheet $parent = null, $columnIndex = 'A')
  28      {
  29          // Set parent and column index
  30          $this->parent = $parent;
  31          $this->columnIndex = $columnIndex;
  32      }
  33  
  34      /**
  35       * Destructor.
  36       */
  37      public function __destruct()
  38      {
  39          unset($this->parent);
  40      }
  41  
  42      /**
  43       * Get column index as string eg: 'A'.
  44       *
  45       * @return string
  46       */
  47      public function getColumnIndex()
  48      {
  49          return $this->columnIndex;
  50      }
  51  
  52      /**
  53       * Get cell iterator.
  54       *
  55       * @param int $startRow The row number at which to start iterating
  56       * @param int $endRow Optionally, the row number at which to stop iterating
  57       *
  58       * @return ColumnCellIterator
  59       */
  60      public function getCellIterator($startRow = 1, $endRow = null)
  61      {
  62          return new ColumnCellIterator($this->parent, $this->columnIndex, $startRow, $endRow);
  63      }
  64  }