diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to '')
-rw-r--r-- | vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php new file mode 100644 index 0000000..2d23a5f --- /dev/null +++ b/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -0,0 +1,131 @@ +<?php
+
+namespace PhpOffice\PhpSpreadsheet\Writer;
+
+abstract class BaseWriter implements IWriter
+{
+ /**
+ * Write charts that are defined in the workbook?
+ * Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object;.
+ *
+ * @var bool
+ */
+ protected $includeCharts = false;
+
+ /**
+ * Pre-calculate formulas
+ * Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
+ * immediately available to MS Excel or other office spreadsheet viewer when opening the file.
+ *
+ * @var bool
+ */
+ protected $preCalculateFormulas = true;
+
+ /**
+ * Use disk caching where possible?
+ *
+ * @var bool
+ */
+ private $useDiskCaching = false;
+
+ /**
+ * Disk caching directory.
+ *
+ * @var string
+ */
+ private $diskCachingDirectory = './';
+
+ /**
+ * @var resource
+ */
+ protected $fileHandle;
+
+ /**
+ * @var bool
+ */
+ private $shouldCloseFile;
+
+ public function getIncludeCharts()
+ {
+ return $this->includeCharts;
+ }
+
+ public function setIncludeCharts($pValue)
+ {
+ $this->includeCharts = (bool) $pValue;
+
+ return $this;
+ }
+
+ public function getPreCalculateFormulas()
+ {
+ return $this->preCalculateFormulas;
+ }
+
+ public function setPreCalculateFormulas($pValue)
+ {
+ $this->preCalculateFormulas = (bool) $pValue;
+
+ return $this;
+ }
+
+ public function getUseDiskCaching()
+ {
+ return $this->useDiskCaching;
+ }
+
+ public function setUseDiskCaching($pValue, $pDirectory = null)
+ {
+ $this->useDiskCaching = $pValue;
+
+ if ($pDirectory !== null) {
+ if (is_dir($pDirectory)) {
+ $this->diskCachingDirectory = $pDirectory;
+ } else {
+ throw new Exception("Directory does not exist: $pDirectory");
+ }
+ }
+
+ return $this;
+ }
+
+ public function getDiskCachingDirectory()
+ {
+ return $this->diskCachingDirectory;
+ }
+
+ /**
+ * Open file handle.
+ *
+ * @param resource|string $filename
+ */
+ public function openFileHandle($filename): void
+ {
+ if (is_resource($filename)) {
+ $this->fileHandle = $filename;
+ $this->shouldCloseFile = false;
+
+ return;
+ }
+
+ $fileHandle = $filename ? fopen($filename, 'wb+') : false;
+ if ($fileHandle === false) {
+ throw new Exception('Could not open file "' . $filename . '" for writing.');
+ }
+
+ $this->fileHandle = $fileHandle;
+ $this->shouldCloseFile = true;
+ }
+
+ /**
+ * Close file handle only if we opened it ourselves.
+ */
+ protected function maybeCloseFileHandle(): void
+ {
+ if ($this->shouldCloseFile) {
+ if (!fclose($this->fileHandle)) {
+ throw new Exception('Could not close file after writing.');
+ }
+ }
+ }
+}
|