Abstract.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2013 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 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.7.9, 2013-06-02
  26. */
  27. /**
  28. * PHPExcel_Writer_Abstract
  29. *
  30. * @category PHPExcel
  31. * @package PHPExcel_Writer
  32. * @copyright Copyright (c) 2006 - 2013 PHPExcel (http://www.codeplex.com/PHPExcel)
  33. */
  34. abstract class PHPExcel_Writer_Abstract implements PHPExcel_Writer_IWriter
  35. {
  36. /**
  37. * Write charts that are defined in the workbook?
  38. * Identifies whether the Writer should write definitions for any charts that exist in the PHPExcel object;
  39. *
  40. * @var boolean
  41. */
  42. protected $_includeCharts = FALSE;
  43. /**
  44. * Pre-calculate formulas
  45. * Forces PHPExcel to recalculate all formulae in a workbook when saving, so that the pre-calculated values are
  46. * immediately available to MS Excel or other office spreadsheet viewer when opening the file
  47. *
  48. * @var boolean
  49. */
  50. protected $_preCalculateFormulas = TRUE;
  51. /**
  52. * Use disk caching where possible?
  53. *
  54. * @var boolean
  55. */
  56. protected $_useDiskCaching = FALSE;
  57. /**
  58. * Disk caching directory
  59. *
  60. * @var string
  61. */
  62. protected $_diskCachingDirectory = './';
  63. /**
  64. * Write charts in workbook?
  65. * If this is true, then the Writer will write definitions for any charts that exist in the PHPExcel object.
  66. * If false (the default) it will ignore any charts defined in the PHPExcel object.
  67. *
  68. * @return boolean
  69. */
  70. public function getIncludeCharts() {
  71. return $this->_includeCharts;
  72. }
  73. /**
  74. * Set write charts in workbook
  75. * Set to true, to advise the Writer to include any charts that exist in the PHPExcel object.
  76. * Set to false (the default) to ignore charts.
  77. *
  78. * @param boolean $pValue
  79. * @return PHPExcel_Writer_IWriter
  80. */
  81. public function setIncludeCharts($pValue = FALSE) {
  82. $this->_includeCharts = (boolean) $pValue;
  83. return $this;
  84. }
  85. /**
  86. * Get Pre-Calculate Formulas flag
  87. * If this is true (the default), then the writer will recalculate all formulae in a workbook when saving,
  88. * so that the pre-calculated values are immediately available to MS Excel or other office spreadsheet
  89. * viewer when opening the file
  90. * If false, then formulae are not calculated on save. This is faster for saving in PHPExcel, but slower
  91. * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself
  92. *
  93. * @return boolean
  94. */
  95. public function getPreCalculateFormulas() {
  96. return $this->_preCalculateFormulas;
  97. }
  98. /**
  99. * Set Pre-Calculate Formulas
  100. * Set to true (the default) to advise the Writer to calculate all formulae on save
  101. * Set to false to prevent precalculation of formulae on save.
  102. *
  103. * @param boolean $pValue Pre-Calculate Formulas?
  104. * @return PHPExcel_Writer_IWriter
  105. */
  106. public function setPreCalculateFormulas($pValue = TRUE) {
  107. $this->_preCalculateFormulas = (boolean) $pValue;
  108. return $this;
  109. }
  110. /**
  111. * Get use disk caching where possible?
  112. *
  113. * @return boolean
  114. */
  115. public function getUseDiskCaching() {
  116. return $this->_useDiskCaching;
  117. }
  118. /**
  119. * Set use disk caching where possible?
  120. *
  121. * @param boolean $pValue
  122. * @param string $pDirectory Disk caching directory
  123. * @throws PHPExcel_Writer_Exception when directory does not exist
  124. * @return PHPExcel_Writer_Excel2007
  125. */
  126. public function setUseDiskCaching($pValue = FALSE, $pDirectory = NULL) {
  127. $this->_useDiskCaching = $pValue;
  128. if ($pDirectory !== NULL) {
  129. if (is_dir($pDirectory)) {
  130. $this->_diskCachingDirectory = $pDirectory;
  131. } else {
  132. throw new PHPExcel_Writer_Exception("Directory does not exist: $pDirectory");
  133. }
  134. }
  135. return $this;
  136. }
  137. /**
  138. * Get disk caching directory
  139. *
  140. * @return string
  141. */
  142. public function getDiskCachingDirectory() {
  143. return $this->_diskCachingDirectory;
  144. }
  145. }