Function.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /**
  3. * PHPExcel_Calculation_Function
  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_Calculation
  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. class PHPExcel_Calculation_Function
  28. {
  29. /* Function categories */
  30. const CATEGORY_CUBE = 'Cube';
  31. const CATEGORY_DATABASE = 'Database';
  32. const CATEGORY_DATE_AND_TIME = 'Date and Time';
  33. const CATEGORY_ENGINEERING = 'Engineering';
  34. const CATEGORY_FINANCIAL = 'Financial';
  35. const CATEGORY_INFORMATION = 'Information';
  36. const CATEGORY_LOGICAL = 'Logical';
  37. const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
  38. const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
  39. const CATEGORY_STATISTICAL = 'Statistical';
  40. const CATEGORY_TEXT_AND_DATA = 'Text and Data';
  41. /**
  42. * Category (represented by CATEGORY_*)
  43. *
  44. * @var string
  45. */
  46. private $category;
  47. /**
  48. * Excel name
  49. *
  50. * @var string
  51. */
  52. private $excelName;
  53. /**
  54. * PHPExcel name
  55. *
  56. * @var string
  57. */
  58. private $phpExcelName;
  59. /**
  60. * Create a new PHPExcel_Calculation_Function
  61. *
  62. * @param string $pCategory Category (represented by CATEGORY_*)
  63. * @param string $pExcelName Excel function name
  64. * @param string $pPHPExcelName PHPExcel function mapping
  65. * @throws PHPExcel_Calculation_Exception
  66. */
  67. public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
  68. {
  69. if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
  70. // Initialise values
  71. $this->category = $pCategory;
  72. $this->excelName = $pExcelName;
  73. $this->phpExcelName = $pPHPExcelName;
  74. } else {
  75. throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
  76. }
  77. }
  78. /**
  79. * Get Category (represented by CATEGORY_*)
  80. *
  81. * @return string
  82. */
  83. public function getCategory()
  84. {
  85. return $this->category;
  86. }
  87. /**
  88. * Set Category (represented by CATEGORY_*)
  89. *
  90. * @param string $value
  91. * @throws PHPExcel_Calculation_Exception
  92. */
  93. public function setCategory($value = null)
  94. {
  95. if (!is_null($value)) {
  96. $this->category = $value;
  97. } else {
  98. throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
  99. }
  100. }
  101. /**
  102. * Get Excel name
  103. *
  104. * @return string
  105. */
  106. public function getExcelName()
  107. {
  108. return $this->excelName;
  109. }
  110. /**
  111. * Set Excel name
  112. *
  113. * @param string $value
  114. */
  115. public function setExcelName($value)
  116. {
  117. $this->excelName = $value;
  118. }
  119. /**
  120. * Get PHPExcel name
  121. *
  122. * @return string
  123. */
  124. public function getPHPExcelName()
  125. {
  126. return $this->phpExcelName;
  127. }
  128. /**
  129. * Set PHPExcel name
  130. *
  131. * @param string $value
  132. */
  133. public function setPHPExcelName($value)
  134. {
  135. $this->phpExcelName = $value;
  136. }
  137. }