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.

Differences Between: [Versions 402 and 403]

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace OpenSpout\Writer\Common\Manager;
   6  
   7  use OpenSpout\Common\Entity\Row;
   8  use OpenSpout\Common\Exception\IOException;
   9  use OpenSpout\Writer\Common\Entity\Sheet;
  10  use OpenSpout\Writer\Common\Entity\Workbook;
  11  use OpenSpout\Writer\Common\Entity\Worksheet;
  12  use OpenSpout\Writer\Exception\SheetNotFoundException;
  13  use OpenSpout\Writer\Exception\WriterException;
  14  
  15  /**
  16   * @internal
  17   */
  18  interface WorkbookManagerInterface
  19  {
  20      /**
  21       * Creates a new sheet in the workbook and make it the current sheet.
  22       * The writing will resume where it stopped (i.e. data won't be truncated).
  23       *
  24       * @return Worksheet The created sheet
  25       *
  26       * @throws IOException If unable to open the sheet for writing
  27       */
  28      public function addNewSheetAndMakeItCurrent(): Worksheet;
  29  
  30      /**
  31       * @return Worksheet[] All the workbook's sheets
  32       */
  33      public function getWorksheets(): array;
  34  
  35      /**
  36       * Returns the current sheet.
  37       *
  38       * @return Worksheet The current sheet
  39       */
  40      public function getCurrentWorksheet(): Worksheet;
  41  
  42      /**
  43       * Sets the given sheet as the current one. New data will be written to this sheet.
  44       * The writing will resume where it stopped (i.e. data won't be truncated).
  45       *
  46       * @param Sheet $sheet The "external" sheet to set as current
  47       *
  48       * @throws SheetNotFoundException If the given sheet does not exist in the workbook
  49       */
  50      public function setCurrentSheet(Sheet $sheet): void;
  51  
  52      /**
  53       * Adds a row to the current sheet.
  54       * If shouldCreateNewSheetsAutomatically option is set to true, it will handle pagination
  55       * with the creation of new worksheets if one worksheet has reached its maximum capicity.
  56       *
  57       * @param Row $row The row to be added
  58       *
  59       * @throws IOException     If trying to create a new sheet and unable to open the sheet for writing
  60       * @throws WriterException If unable to write data
  61       */
  62      public function addRowToCurrentWorksheet(Row $row): void;
  63  
  64      /**
  65       * Closes the workbook and all its associated sheets.
  66       * All the necessary files are written to disk and zipped together to create the final file.
  67       * All the temporary files are then deleted.
  68       *
  69       * @param resource $finalFilePointer Pointer to the spreadsheet that will be created
  70       */
  71      public function close($finalFilePointer): void;
  72  }