Abstract.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * PHPExcel_Writer_Abstract
  4. *
  5. * Copyright (c) 2006 - 2015 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Writer
  23. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version ##VERSION##, ##DATE##
  26. */
  27. abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
  28. {
  29. /**
  30. * Write charts that are defined in the workbook?
  31. * Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
  32. *
  33. * @var boolean
  34. */
  35. protected $includeCharts = false;
  36. /**
  37. * Pre-calculate formulas
  38. * Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
  39. * immediately available to MS Excel or other office spreadsheet viewer when opening the file
  40. *
  41. * @var boolean
  42. */
  43. protected $preCalculateFormulas = true;
  44. /**
  45. * Use disk caching where possible?
  46. *
  47. * @var boolean
  48. */
  49. protected $_useDiskCaching = false;
  50. /**
  51. * Disk caching directory
  52. *
  53. * @var string
  54. */
  55. protected $_diskCachingDirectory = './';
  56. /**
  57. * Write charts in workbook?
  58. * If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object.
  59. * If false (the default) it will ignore any charts defined in the PHPExcel object.
  60. *
  61. * @return boolean
  62. */
  63. public function getIncludeCharts()
  64. {
  65. return $this->includeCharts;
  66. }
  67. /**
  68. * Set write charts in workbook
  69. * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object.
  70. * Set to false (the default) to ignore charts.
  71. *
  72. * @param boolean $pValue
  73. * @return PHPExcel_Writer_IWriter
  74. */
  75. public function setIncludeCharts($pValue = false)
  76. {
  77. $this->includeCharts = (boolean) $pValue;
  78. return $this;
  79. }
  80. /**
  81. * Get Pre-Calculate Formulas flag
  82. * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
  83. * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
  84. * viewer when opening the file
  85. * If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
  86. * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
  87. *
  88. * @return boolean
  89. */
  90. public function getPreCalculateFormulas()
  91. {
  92. return $this->preCalculateFormulas;
  93. }
  94. /**
  95. * Set Pre-Calculate Formulas
  96. * Set to true (the default) to advise the Writer to calculate all formulae on save
  97. * Set to false to prevent precalculation of formulae on save.
  98. *
  99. * @param boolean $pValue Pre-Calculate Formulas?
  100. * @return PHPExcel_Writer_IWriter
  101. */
  102. public function setPreCalculateFormulas($pValue = true)
  103. {
  104. $this->preCalculateFormulas = (boolean) $pValue;
  105. return $this;
  106. }
  107. /**
  108. * Get use disk caching where possible?
  109. *
  110. * @return boolean
  111. */
  112. public function getUseDiskCaching()
  113. {
  114. return $this->_useDiskCaching;
  115. }
  116. /**
  117. * Set use disk caching where possible?
  118. *
  119. * @param boolean $pValue
  120. * @param string $pDirectory Disk caching directory
  121. * @throws PHPExcel_Writer_Exception when directory does not exist
  122. * @return PHPExcel_Writer_Excel2007
  123. */
  124. public function setUseDiskCaching($pValue = false, $pDirectory = null)
  125. {
  126. $this->_useDiskCaching = $pValue;
  127. if ($pDirectory !== null) {
  128. if (is_dir($pDirectory)) {
  129. $this->_diskCachingDirectory = $pDirectory;
  130. } else {
  131. throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
  132. }
  133. }
  134. return $this;
  135. }
  136. /**
  137. * Get disk caching directory
  138. *
  139. * @return string
  140. */
  141. public function getDiskCachingDirectory()
  142. {
  143. return $this->_diskCachingDirectory;
  144. }
  145. }