PHPExcelFunction.Class.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: phperstar
  5. * Date: 2020/8/11
  6. * Time: 6:54 PM
  7. */
  8. namespace Util\PHPExcel\Calculation;
  9. class PHPExcelFunction
  10. {
  11. /* Function categories */
  12. const CATEGORY_CUBE = 'Cube';
  13. const CATEGORY_DATABASE = 'Database';
  14. const CATEGORY_DATE_AND_TIME = 'Date and Time';
  15. const CATEGORY_ENGINEERING = 'Engineering';
  16. const CATEGORY_FINANCIAL = 'Financial';
  17. const CATEGORY_INFORMATION = 'Information';
  18. const CATEGORY_LOGICAL = 'Logical';
  19. const CATEGORY_LOOKUP_AND_REFERENCE = 'Lookup and Reference';
  20. const CATEGORY_MATH_AND_TRIG = 'Math and Trig';
  21. const CATEGORY_STATISTICAL = 'Statistical';
  22. const CATEGORY_TEXT_AND_DATA = 'Text and Data';
  23. /**
  24. * Category (represented by CATEGORY_*)
  25. *
  26. * @var string
  27. */
  28. private $category;
  29. /**
  30. * Excel name
  31. *
  32. * @var string
  33. */
  34. private $excelName;
  35. /**
  36. * PHPExcel name
  37. *
  38. * @var string
  39. */
  40. private $phpExcelName;
  41. /**
  42. * Create a new PHPExcel_Calculation_Function
  43. *
  44. * @param string $pCategory Category (represented by CATEGORY_*)
  45. * @param string $pExcelName Excel function name
  46. * @param string $pPHPExcelName PHPExcel function mapping
  47. * @throws PHPExcel_Calculation_Exception
  48. */
  49. public function __construct($pCategory = null, $pExcelName = null, $pPHPExcelName = null)
  50. {
  51. if (($pCategory !== null) && ($pExcelName !== null) && ($pPHPExcelName !== null)) {
  52. // Initialise values
  53. $this->category = $pCategory;
  54. $this->excelName = $pExcelName;
  55. $this->phpExcelName = $pPHPExcelName;
  56. } else {
  57. throw new PHPExcel_Calculation_Exception("Invalid parameters passed.");
  58. }
  59. }
  60. /**
  61. * Get Category (represented by CATEGORY_*)
  62. *
  63. * @return string
  64. */
  65. public function getCategory()
  66. {
  67. return $this->category;
  68. }
  69. /**
  70. * Set Category (represented by CATEGORY_*)
  71. *
  72. * @param string $value
  73. * @throws PHPExcel_Calculation_Exception
  74. */
  75. public function setCategory($value = null)
  76. {
  77. if (!is_null($value)) {
  78. $this->category = $value;
  79. } else {
  80. throw new PHPExcel_Calculation_Exception("Invalid parameter passed.");
  81. }
  82. }
  83. /**
  84. * Get Excel name
  85. *
  86. * @return string
  87. */
  88. public function getExcelName()
  89. {
  90. return $this->excelName;
  91. }
  92. /**
  93. * Set Excel name
  94. *
  95. * @param string $value
  96. */
  97. public function setExcelName($value)
  98. {
  99. $this->excelName = $value;
  100. }
  101. /**
  102. * Get PHPExcel name
  103. *
  104. * @return string
  105. */
  106. public function getPHPExcelName()
  107. {
  108. return $this->phpExcelName;
  109. }
  110. /**
  111. * Set PHPExcel name
  112. *
  113. * @param string $value
  114. */
  115. public function setPHPExcelName($value)
  116. {
  117. $this->phpExcelName = $value;
  118. }
  119. }