Abstract.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
  8. {
  9. /**
  10. * Write charts that are defined in the workbook?
  11. * Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
  12. *
  13. * @var boolean
  14. */
  15. protected $includeCharts = false;
  16. /**
  17. * Pre-calculate formulas
  18. * Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
  19. * immediately available to MS Excel or other office spreadsheet viewer when opening the file
  20. *
  21. * @var boolean
  22. */
  23. protected $preCalculateFormulas = true;
  24. /**
  25. * Use disk caching where possible?
  26. *
  27. * @var boolean
  28. */
  29. protected $_useDiskCaching = false;
  30. /**
  31. * Disk caching directory
  32. *
  33. * @var string
  34. */
  35. protected $_diskCachingDirectory = './';
  36. /**
  37. * Write charts in workbook?
  38. * If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object.
  39. * If false (the default) it will ignore any charts defined in the PHPExcel object.
  40. *
  41. * @return boolean
  42. */
  43. public function getIncludeCharts()
  44. {
  45. return $this->includeCharts;
  46. }
  47. /**
  48. * Set write charts in workbook
  49. * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object.
  50. * Set to false (the default) to ignore charts.
  51. *
  52. * @param boolean $pValue
  53. * @return PHPExcel_Writer_IWriter
  54. */
  55. public function setIncludeCharts($pValue = false)
  56. {
  57. $this->includeCharts = (boolean) $pValue;
  58. return $this;
  59. }
  60. /**
  61. * Get Pre-Calculate Formulas flag
  62. * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
  63. * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
  64. * viewer when opening the file
  65. * If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
  66. * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
  67. *
  68. * @return boolean
  69. */
  70. public function getPreCalculateFormulas()
  71. {
  72. return $this->preCalculateFormulas;
  73. }
  74. /**
  75. * Set Pre-Calculate Formulas
  76. * Set to true (the default) to advise the Writer to calculate all formulae on save
  77. * Set to false to prevent precalculation of formulae on save.
  78. *
  79. * @param boolean $pValue Pre-Calculate Formulas?
  80. * @return PHPExcel_Writer_IWriter
  81. */
  82. public function setPreCalculateFormulas($pValue = true)
  83. {
  84. $this->preCalculateFormulas = (boolean) $pValue;
  85. return $this;
  86. }
  87. /**
  88. * Get use disk caching where possible?
  89. *
  90. * @return boolean
  91. */
  92. public function getUseDiskCaching()
  93. {
  94. return $this->_useDiskCaching;
  95. }
  96. /**
  97. * Set use disk caching where possible?
  98. *
  99. * @param boolean $pValue
  100. * @param string $pDirectory Disk caching directory
  101. * @throws PHPExcel_Writer_Exception when directory does not exist
  102. * @return PHPExcel_Writer_Excel2007
  103. */
  104. public function setUseDiskCaching($pValue = false, $pDirectory = null)
  105. {
  106. $this->_useDiskCaching = $pValue;
  107. if ($pDirectory !== null) {
  108. if (is_dir($pDirectory)) {
  109. $this->_diskCachingDirectory = $pDirectory;
  110. } else {
  111. throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
  112. }
  113. }
  114. return $this;
  115. }
  116. /**
  117. * Get disk caching directory
  118. *
  119. * @return string
  120. */
  121. public function getDiskCachingDirectory()
  122. {
  123. return $this->_diskCachingDirectory;
  124. }
  125. }