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