Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace OpenSpout\Writer\XLSX;
   6  
   7  use OpenSpout\Common\Entity\Style\Style;
   8  use OpenSpout\Writer\Common\AbstractOptions;
   9  
  10  final class Options extends AbstractOptions
  11  {
  12      public const DEFAULT_FONT_SIZE = 12;
  13      public const DEFAULT_FONT_NAME = 'Calibri';
  14  
  15      public bool $SHOULD_USE_INLINE_STRINGS = true;
  16  
  17      /** @var MergeCell[] */
  18      private array $MERGE_CELLS = [];
  19  
  20      public function __construct()
  21      {
  22          parent::__construct();
  23  
  24          $defaultRowStyle = new Style();
  25          $defaultRowStyle->setFontSize(self::DEFAULT_FONT_SIZE);
  26          $defaultRowStyle->setFontName(self::DEFAULT_FONT_NAME);
  27  
  28          $this->DEFAULT_ROW_STYLE = $defaultRowStyle;
  29      }
  30  
  31      /**
  32       * Row coordinates are indexed from 1, columns from 0 (A = 0),
  33       * so a merge B2:G2 looks like $writer->mergeCells(1, 2, 6, 2);.
  34       *
  35       * @param 0|positive-int $topLeftColumn
  36       * @param positive-int   $topLeftRow
  37       * @param 0|positive-int $bottomRightColumn
  38       * @param positive-int   $bottomRightRow
  39       * @param 0|positive-int $sheetIndex
  40       */
  41      public function mergeCells(
  42          int $topLeftColumn,
  43          int $topLeftRow,
  44          int $bottomRightColumn,
  45          int $bottomRightRow,
  46          int $sheetIndex = 0,
  47      ): void {
  48          $this->MERGE_CELLS[] = new MergeCell(
  49              $sheetIndex,
  50              $topLeftColumn,
  51              $topLeftRow,
  52              $bottomRightColumn,
  53              $bottomRightRow
  54          );
  55      }
  56  
  57      /**
  58       * @return MergeCell[]
  59       *
  60       * @internal
  61       */
  62      public function getMergeCells(): array
  63      {
  64          return $this->MERGE_CELLS;
  65      }
  66  }