Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  
   3  namespace PhpOffice\PhpSpreadsheet\Writer;
   4  
   5  use PhpOffice\PhpSpreadsheet\Spreadsheet;
   6  
   7  interface IWriter
   8  {
   9      public const SAVE_WITH_CHARTS = 1;
  10  
  11      /**
  12       * IWriter constructor.
  13       *
  14       * @param Spreadsheet $spreadsheet The spreadsheet that we want to save using this Writer
  15       */
  16      public function __construct(Spreadsheet $spreadsheet);
  17  
  18      /**
  19       * Write charts in workbook?
  20       *        If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object.
  21       *        If false (the default) it will ignore any charts defined in the PhpSpreadsheet object.
  22       *
  23       * @return bool
  24       */
  25      public function getIncludeCharts();
  26  
  27      /**
  28       * Set write charts in workbook
  29       *        Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object.
  30       *        Set to false (the default) to ignore charts.
  31       *
  32       * @param bool $includeCharts
  33       *
  34       * @return IWriter
  35       */
  36      public function setIncludeCharts($includeCharts);
  37  
  38      /**
  39       * Get Pre-Calculate Formulas flag
  40       *     If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
  41       *        so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
  42       *        viewer when opening the file
  43       *     If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower
  44       *        when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself.
  45       *
  46       * @return bool
  47       */
  48      public function getPreCalculateFormulas();
  49  
  50      /**
  51       * Set Pre-Calculate Formulas
  52       *        Set to true (the default) to advise the Writer to calculate all formulae on save
  53       *        Set to false to prevent precalculation of formulae on save.
  54       *
  55       * @param bool $precalculateFormulas Pre-Calculate Formulas?
  56       *
  57       * @return IWriter
  58       */
  59      public function setPreCalculateFormulas($precalculateFormulas);
  60  
  61      /**
  62       * Save PhpSpreadsheet to file.
  63       *
  64       * @param resource|string $filename Name of the file to save
  65       *
  66       * @throws Exception
  67       */
  68      public function save($filename, int $flags = 0): void;
  69  
  70      /**
  71       * Get use disk caching where possible?
  72       *
  73       * @return bool
  74       */
  75      public function getUseDiskCaching();
  76  
  77      /**
  78       * Set use disk caching where possible?
  79       *
  80       * @param bool $useDiskCache
  81       * @param string $cacheDirectory Disk caching directory
  82       *
  83       * @return IWriter
  84       */
  85      public function setUseDiskCaching($useDiskCache, $cacheDirectory = null);
  86  
  87      /**
  88       * Get disk caching directory.
  89       *
  90       * @return string
  91       */
  92      public function getDiskCachingDirectory();
  93  }