Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.
   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace OpenSpout\Reader\XLSX;
   6  
   7  use OpenSpout\Reader\Common\ColumnWidth;
   8  use OpenSpout\Reader\SheetWithVisibilityInterface;
   9  
  10  /**
  11   * @implements SheetWithVisibilityInterface<RowIterator>
  12   */
  13  final class Sheet implements SheetWithVisibilityInterface
  14  {
  15      /** @var RowIterator To iterate over sheet's rows */
  16      private RowIterator $rowIterator;
  17  
  18      /** @var SheetHeaderReader To read the header of the sheet, containing for instance the col widths */
  19      private SheetHeaderReader $headerReader;
  20  
  21      /** @var int Index of the sheet, based on order in the workbook (zero-based) */
  22      private int $index;
  23  
  24      /** @var string Name of the sheet */
  25      private string $name;
  26  
  27      /** @var bool Whether the sheet was the active one */
  28      private bool $isActive;
  29  
  30      /** @var bool Whether the sheet is visible */
  31      private bool $isVisible;
  32  
  33      /**
  34       * @param RowIterator $rowIterator    The corresponding row iterator
  35       * @param int         $sheetIndex     Index of the sheet, based on order in the workbook (zero-based)
  36       * @param string      $sheetName      Name of the sheet
  37       * @param bool        $isSheetActive  Whether the sheet was defined as active
  38       * @param bool        $isSheetVisible Whether the sheet is visible
  39       */
  40      public function __construct(RowIterator $rowIterator, SheetHeaderReader $headerReader, int $sheetIndex, string $sheetName, bool $isSheetActive, bool $isSheetVisible)
  41      {
  42          $this->rowIterator = $rowIterator;
  43          $this->headerReader = $headerReader;
  44          $this->index = $sheetIndex;
  45          $this->name = $sheetName;
  46          $this->isActive = $isSheetActive;
  47          $this->isVisible = $isSheetVisible;
  48      }
  49  
  50      public function getRowIterator(): RowIterator
  51      {
  52          return $this->rowIterator;
  53      }
  54  
  55      /**
  56       * @return ColumnWidth[] a list of column-widths
  57       */
  58      public function getColumnWidths(): array
  59      {
  60          return $this->headerReader->getColumnWidths();
  61      }
  62  
  63      /**
  64       * @return int Index of the sheet, based on order in the workbook (zero-based)
  65       */
  66      public function getIndex(): int
  67      {
  68          return $this->index;
  69      }
  70  
  71      /**
  72       * @return string Name of the sheet
  73       */
  74      public function getName(): string
  75      {
  76          return $this->name;
  77      }
  78  
  79      /**
  80       * @return bool Whether the sheet was defined as active
  81       */
  82      public function isActive(): bool
  83      {
  84          return $this->isActive;
  85      }
  86  
  87      /**
  88       * @return bool Whether the sheet is visible
  89       */
  90      public function isVisible(): bool
  91      {
  92          return $this->isVisible;
  93      }
  94  }