BaseWriter.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheet\Writer;
  3. abstract class BaseWriter implements IWriter
  4. {
  5. /**
  6. * Write charts that are defined in the workbook?
  7. * Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object;.
  8. *
  9. * @var bool
  10. */
  11. protected $includeCharts = false;
  12. /**
  13. * Pre-calculate formulas
  14. * Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
  15. * immediately available to MS Excel or other office spreadsheet viewer when opening the file.
  16. *
  17. * @var bool
  18. */
  19. protected $preCalculateFormulas = true;
  20. /**
  21. * Use disk caching where possible?
  22. *
  23. * @var bool
  24. */
  25. private $useDiskCaching = false;
  26. /**
  27. * Disk caching directory.
  28. *
  29. * @var string
  30. */
  31. private $diskCachingDirectory = './';
  32. public function getIncludeCharts()
  33. {
  34. return $this->includeCharts;
  35. }
  36. public function setIncludeCharts($pValue)
  37. {
  38. $this->includeCharts = (bool) $pValue;
  39. return $this;
  40. }
  41. public function getPreCalculateFormulas()
  42. {
  43. return $this->preCalculateFormulas;
  44. }
  45. public function setPreCalculateFormulas($pValue)
  46. {
  47. $this->preCalculateFormulas = (bool) $pValue;
  48. return $this;
  49. }
  50. public function getUseDiskCaching()
  51. {
  52. return $this->useDiskCaching;
  53. }
  54. public function setUseDiskCaching($pValue, $pDirectory = null)
  55. {
  56. $this->useDiskCaching = $pValue;
  57. if ($pDirectory !== null) {
  58. if (is_dir($pDirectory)) {
  59. $this->diskCachingDirectory = $pDirectory;
  60. } else {
  61. throw new Exception("Directory does not exist: $pDirectory");
  62. }
  63. }
  64. return $this;
  65. }
  66. public function getDiskCachingDirectory()
  67. {
  68. return $this->diskCachingDirectory;
  69. }
  70. }