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;
   6  
   7  use OpenSpout\Common\Entity\Row;
   8  
   9  interface WriterInterface
  10  {
  11      /**
  12       * Initializes the writer and opens it to accept data.
  13       * By using this method, the data will be written to a file.
  14       *
  15       * @param string $outputFilePath Path of the output file that will contain the data
  16       *
  17       * @throws \OpenSpout\Common\Exception\IOException If the writer cannot be opened or if the given path is not writable
  18       */
  19      public function openToFile(string $outputFilePath): void;
  20  
  21      /**
  22       * Initializes the writer and opens it to accept data.
  23       * By using this method, the data will be outputted directly to the browser.
  24       *
  25       * @param string $outputFileName Name of the output file that will contain the data. If a path is passed in, only the file name will be kept
  26       *
  27       * @throws \OpenSpout\Common\Exception\IOException If the writer cannot be opened
  28       */
  29      public function openToBrowser(string $outputFileName): void;
  30  
  31      /**
  32       * Appends a row to the end of the stream.
  33       *
  34       * @param Row $row The row to be appended to the stream
  35       *
  36       * @throws \OpenSpout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet
  37       * @throws \OpenSpout\Common\Exception\IOException              If unable to write data
  38       */
  39      public function addRow(Row $row): void;
  40  
  41      /**
  42       * Appends the rows to the end of the stream.
  43       *
  44       * @param Row[] $rows The rows to be appended to the stream
  45       *
  46       * @throws \OpenSpout\Common\Exception\InvalidArgumentException If the input param is not valid
  47       * @throws \OpenSpout\Writer\Exception\WriterNotOpenedException If the writer has not been opened yet
  48       * @throws \OpenSpout\Common\Exception\IOException              If unable to write data
  49       */
  50      public function addRows(array $rows): void;
  51  
  52      /**
  53       * @return 0|positive-int
  54       */
  55      public function getWrittenRowCount(): int;
  56  
  57      /**
  58       * Closes the writer. This will close the streamer as well, preventing new data
  59       * to be written to the file.
  60       */
  61      public function close(): void;
  62  }