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.
   1  <?php
   2  
   3  namespace Box\Spout\Writer\XLSX;
   4  
   5  use Box\Spout\Writer\Common\Entity\Options;
   6  use Box\Spout\Writer\WriterMultiSheetsAbstract;
   7  
   8  /**
   9   * Class Writer
  10   * This class provides base support to write data to XLSX files
  11   */
  12  class Writer extends WriterMultiSheetsAbstract
  13  {
  14      /** @var string Content-Type value for the header */
  15      protected static $headerContentType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  16  
  17      /**
  18       * Sets a custom temporary folder for creating intermediate files/folders.
  19       * This must be set before opening the writer.
  20       *
  21       * @param string $tempFolder Temporary folder where the files to create the XLSX will be stored
  22       * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened
  23       * @return Writer
  24       */
  25      public function setTempFolder($tempFolder)
  26      {
  27          $this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
  28  
  29          $this->optionsManager->setOption(Options::TEMP_FOLDER, $tempFolder);
  30  
  31          return $this;
  32      }
  33  
  34      /**
  35       * Use inline string to be more memory efficient. If set to false, it will use shared strings.
  36       * This must be set before opening the writer.
  37       *
  38       * @param bool $shouldUseInlineStrings Whether inline or shared strings should be used
  39       * @throws \Box\Spout\Writer\Exception\WriterAlreadyOpenedException If the writer was already opened
  40       * @return Writer
  41       */
  42      public function setShouldUseInlineStrings($shouldUseInlineStrings)
  43      {
  44          $this->throwIfWriterAlreadyOpened('Writer must be configured before opening it.');
  45  
  46          $this->optionsManager->setOption(Options::SHOULD_USE_INLINE_STRINGS, $shouldUseInlineStrings);
  47  
  48          return $this;
  49      }
  50  }