Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Worksheet\Table;
   4  
   5  use PhpOffice\PhpSpreadsheet\Worksheet\Table;
   6  
   7  class Column
   8  {
   9      /**
  10       * Table Column Index.
  11       *
  12       * @var string
  13       */
  14      private $columnIndex = '';
  15  
  16      /**
  17       * Show Filter Button.
  18       *
  19       * @var bool
  20       */
  21      private $showFilterButton = true;
  22  
  23      /**
  24       * Total Row Label.
  25       *
  26       * @var string
  27       */
  28      private $totalsRowLabel;
  29  
  30      /**
  31       * Total Row Function.
  32       *
  33       * @var string
  34       */
  35      private $totalsRowFunction;
  36  
  37      /**
  38       * Total Row Formula.
  39       *
  40       * @var string
  41       */
  42      private $totalsRowFormula;
  43  
  44      /**
  45       * Column Formula.
  46       *
  47       * @var string
  48       */
  49      private $columnFormula;
  50  
  51      /**
  52       * Table.
  53       *
  54       * @var null|Table
  55       */
  56      private $table;
  57  
  58      /**
  59       * Create a new Column.
  60       *
  61       * @param string $column Column (e.g. A)
  62       * @param Table $table Table for this column
  63       */
  64      public function __construct($column, ?Table $table = null)
  65      {
  66          $this->columnIndex = $column;
  67          $this->table = $table;
  68      }
  69  
  70      /**
  71       * Get Table column index as string eg: 'A'.
  72       */
  73      public function getColumnIndex(): string
  74      {
  75          return $this->columnIndex;
  76      }
  77  
  78      /**
  79       * Set Table column index as string eg: 'A'.
  80       *
  81       * @param string $column Column (e.g. A)
  82       */
  83      public function setColumnIndex($column): self
  84      {
  85          // Uppercase coordinate
  86          $column = strtoupper($column);
  87          if ($this->table !== null) {
  88              $this->table->isColumnInRange($column);
  89          }
  90  
  91          $this->columnIndex = $column;
  92  
  93          return $this;
  94      }
  95  
  96      /**
  97       * Get show Filter Button.
  98       */
  99      public function getShowFilterButton(): bool
 100      {
 101          return $this->showFilterButton;
 102      }
 103  
 104      /**
 105       * Set show Filter Button.
 106       */
 107      public function setShowFilterButton(bool $showFilterButton): self
 108      {
 109          $this->showFilterButton = $showFilterButton;
 110  
 111          return $this;
 112      }
 113  
 114      /**
 115       * Get total Row Label.
 116       */
 117      public function getTotalsRowLabel(): ?string
 118      {
 119          return $this->totalsRowLabel;
 120      }
 121  
 122      /**
 123       * Set total Row Label.
 124       */
 125      public function setTotalsRowLabel(string $totalsRowLabel): self
 126      {
 127          $this->totalsRowLabel = $totalsRowLabel;
 128  
 129          return $this;
 130      }
 131  
 132      /**
 133       * Get total Row Function.
 134       */
 135      public function getTotalsRowFunction(): ?string
 136      {
 137          return $this->totalsRowFunction;
 138      }
 139  
 140      /**
 141       * Set total Row Function.
 142       */
 143      public function setTotalsRowFunction(string $totalsRowFunction): self
 144      {
 145          $this->totalsRowFunction = $totalsRowFunction;
 146  
 147          return $this;
 148      }
 149  
 150      /**
 151       * Get total Row Formula.
 152       */
 153      public function getTotalsRowFormula(): ?string
 154      {
 155          return $this->totalsRowFormula;
 156      }
 157  
 158      /**
 159       * Set total Row Formula.
 160       */
 161      public function setTotalsRowFormula(string $totalsRowFormula): self
 162      {
 163          $this->totalsRowFormula = $totalsRowFormula;
 164  
 165          return $this;
 166      }
 167  
 168      /**
 169       * Get column Formula.
 170       */
 171      public function getColumnFormula(): ?string
 172      {
 173          return $this->columnFormula;
 174      }
 175  
 176      /**
 177       * Set column Formula.
 178       */
 179      public function setColumnFormula(string $columnFormula): self
 180      {
 181          $this->columnFormula = $columnFormula;
 182  
 183          return $this;
 184      }
 185  
 186      /**
 187       * Get this Column's Table.
 188       */
 189      public function getTable(): ?Table
 190      {
 191          return $this->table;
 192      }
 193  
 194      /**
 195       * Set this Column's Table.
 196       */
 197      public function setTable(?Table $table = null): self
 198      {
 199          $this->table = $table;
 200  
 201          return $this;
 202      }
 203  }