DataValidation.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. class PHPExcel_Cell_DataValidation
  8. {
  9. /* Data validation types */
  10. const TYPE_NONE = 'none';
  11. const TYPE_CUSTOM = 'custom';
  12. const TYPE_DATE = 'date';
  13. const TYPE_DECIMAL = 'decimal';
  14. const TYPE_LIST = 'list';
  15. const TYPE_TEXTLENGTH = 'textLength';
  16. const TYPE_TIME = 'time';
  17. const TYPE_WHOLE = 'whole';
  18. /* Data validation error styles */
  19. const STYLE_STOP = 'stop';
  20. const STYLE_WARNING = 'warning';
  21. const STYLE_INFORMATION = 'information';
  22. /* Data validation operators */
  23. const OPERATOR_BETWEEN = 'between';
  24. const OPERATOR_EQUAL = 'equal';
  25. const OPERATOR_GREATERTHAN = 'greaterThan';
  26. const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
  27. const OPERATOR_LESSTHAN = 'lessThan';
  28. const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
  29. const OPERATOR_NOTBETWEEN = 'notBetween';
  30. const OPERATOR_NOTEQUAL = 'notEqual';
  31. /**
  32. * Formula 1
  33. *
  34. * @var string
  35. */
  36. private $formula1;
  37. /**
  38. * Formula 2
  39. *
  40. * @var string
  41. */
  42. private $formula2;
  43. /**
  44. * Type
  45. *
  46. * @var string
  47. */
  48. private $type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  49. /**
  50. * Error style
  51. *
  52. * @var string
  53. */
  54. private $errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  55. /**
  56. * Operator
  57. *
  58. * @var string
  59. */
  60. private $operator;
  61. /**
  62. * Allow Blank
  63. *
  64. * @var boolean
  65. */
  66. private $allowBlank;
  67. /**
  68. * Show DropDown
  69. *
  70. * @var boolean
  71. */
  72. private $showDropDown;
  73. /**
  74. * Show InputMessage
  75. *
  76. * @var boolean
  77. */
  78. private $showInputMessage;
  79. /**
  80. * Show ErrorMessage
  81. *
  82. * @var boolean
  83. */
  84. private $showErrorMessage;
  85. /**
  86. * Error title
  87. *
  88. * @var string
  89. */
  90. private $errorTitle;
  91. /**
  92. * Error
  93. *
  94. * @var string
  95. */
  96. private $error;
  97. /**
  98. * Prompt title
  99. *
  100. * @var string
  101. */
  102. private $promptTitle;
  103. /**
  104. * Prompt
  105. *
  106. * @var string
  107. */
  108. private $prompt;
  109. /**
  110. * Create a new PHPExcel_Cell_DataValidation
  111. */
  112. public function __construct()
  113. {
  114. // Initialise member variables
  115. $this->formula1 = '';
  116. $this->formula2 = '';
  117. $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE;
  118. $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP;
  119. $this->operator = '';
  120. $this->allowBlank = false;
  121. $this->showDropDown = false;
  122. $this->showInputMessage = false;
  123. $this->showErrorMessage = false;
  124. $this->errorTitle = '';
  125. $this->error = '';
  126. $this->promptTitle = '';
  127. $this->prompt = '';
  128. }
  129. /**
  130. * Get Formula 1
  131. *
  132. * @return string
  133. */
  134. public function getFormula1()
  135. {
  136. return $this->formula1;
  137. }
  138. /**
  139. * Set Formula 1
  140. *
  141. * @param string $value
  142. * @return PHPExcel_Cell_DataValidation
  143. */
  144. public function setFormula1($value = '')
  145. {
  146. $this->formula1 = $value;
  147. return $this;
  148. }
  149. /**
  150. * Get Formula 2
  151. *
  152. * @return string
  153. */
  154. public function getFormula2()
  155. {
  156. return $this->formula2;
  157. }
  158. /**
  159. * Set Formula 2
  160. *
  161. * @param string $value
  162. * @return PHPExcel_Cell_DataValidation
  163. */
  164. public function setFormula2($value = '')
  165. {
  166. $this->formula2 = $value;
  167. return $this;
  168. }
  169. /**
  170. * Get Type
  171. *
  172. * @return string
  173. */
  174. public function getType()
  175. {
  176. return $this->type;
  177. }
  178. /**
  179. * Set Type
  180. *
  181. * @param string $value
  182. * @return PHPExcel_Cell_DataValidation
  183. */
  184. public function setType($value = PHPExcel_Cell_DataValidation::TYPE_NONE)
  185. {
  186. $this->type = $value;
  187. return $this;
  188. }
  189. /**
  190. * Get Error style
  191. *
  192. * @return string
  193. */
  194. public function getErrorStyle()
  195. {
  196. return $this->errorStyle;
  197. }
  198. /**
  199. * Set Error style
  200. *
  201. * @param string $value
  202. * @return PHPExcel_Cell_DataValidation
  203. */
  204. public function setErrorStyle($value = PHPExcel_Cell_DataValidation::STYLE_STOP)
  205. {
  206. $this->errorStyle = $value;
  207. return $this;
  208. }
  209. /**
  210. * Get Operator
  211. *
  212. * @return string
  213. */
  214. public function getOperator()
  215. {
  216. return $this->operator;
  217. }
  218. /**
  219. * Set Operator
  220. *
  221. * @param string $value
  222. * @return PHPExcel_Cell_DataValidation
  223. */
  224. public function setOperator($value = '')
  225. {
  226. $this->operator = $value;
  227. return $this;
  228. }
  229. /**
  230. * Get Allow Blank
  231. *
  232. * @return boolean
  233. */
  234. public function getAllowBlank()
  235. {
  236. return $this->allowBlank;
  237. }
  238. /**
  239. * Set Allow Blank
  240. *
  241. * @param boolean $value
  242. * @return PHPExcel_Cell_DataValidation
  243. */
  244. public function setAllowBlank($value = false)
  245. {
  246. $this->allowBlank = $value;
  247. return $this;
  248. }
  249. /**
  250. * Get Show DropDown
  251. *
  252. * @return boolean
  253. */
  254. public function getShowDropDown()
  255. {
  256. return $this->showDropDown;
  257. }
  258. /**
  259. * Set Show DropDown
  260. *
  261. * @param boolean $value
  262. * @return PHPExcel_Cell_DataValidation
  263. */
  264. public function setShowDropDown($value = false)
  265. {
  266. $this->showDropDown = $value;
  267. return $this;
  268. }
  269. /**
  270. * Get Show InputMessage
  271. *
  272. * @return boolean
  273. */
  274. public function getShowInputMessage()
  275. {
  276. return $this->showInputMessage;
  277. }
  278. /**
  279. * Set Show InputMessage
  280. *
  281. * @param boolean $value
  282. * @return PHPExcel_Cell_DataValidation
  283. */
  284. public function setShowInputMessage($value = false)
  285. {
  286. $this->showInputMessage = $value;
  287. return $this;
  288. }
  289. /**
  290. * Get Show ErrorMessage
  291. *
  292. * @return boolean
  293. */
  294. public function getShowErrorMessage()
  295. {
  296. return $this->showErrorMessage;
  297. }
  298. /**
  299. * Set Show ErrorMessage
  300. *
  301. * @param boolean $value
  302. * @return PHPExcel_Cell_DataValidation
  303. */
  304. public function setShowErrorMessage($value = false)
  305. {
  306. $this->showErrorMessage = $value;
  307. return $this;
  308. }
  309. /**
  310. * Get Error title
  311. *
  312. * @return string
  313. */
  314. public function getErrorTitle()
  315. {
  316. return $this->errorTitle;
  317. }
  318. /**
  319. * Set Error title
  320. *
  321. * @param string $value
  322. * @return PHPExcel_Cell_DataValidation
  323. */
  324. public function setErrorTitle($value = '')
  325. {
  326. $this->errorTitle = $value;
  327. return $this;
  328. }
  329. /**
  330. * Get Error
  331. *
  332. * @return string
  333. */
  334. public function getError()
  335. {
  336. return $this->error;
  337. }
  338. /**
  339. * Set Error
  340. *
  341. * @param string $value
  342. * @return PHPExcel_Cell_DataValidation
  343. */
  344. public function setError($value = '')
  345. {
  346. $this->error = $value;
  347. return $this;
  348. }
  349. /**
  350. * Get Prompt title
  351. *
  352. * @return string
  353. */
  354. public function getPromptTitle()
  355. {
  356. return $this->promptTitle;
  357. }
  358. /**
  359. * Set Prompt title
  360. *
  361. * @param string $value
  362. * @return PHPExcel_Cell_DataValidation
  363. */
  364. public function setPromptTitle($value = '')
  365. {
  366. $this->promptTitle = $value;
  367. return $this;
  368. }
  369. /**
  370. * Get Prompt
  371. *
  372. * @return string
  373. */
  374. public function getPrompt()
  375. {
  376. return $this->prompt;
  377. }
  378. /**
  379. * Set Prompt
  380. *
  381. * @param string $value
  382. * @return PHPExcel_Cell_DataValidation
  383. */
  384. public function setPrompt($value = '')
  385. {
  386. $this->prompt = $value;
  387. return $this;
  388. }
  389. /**
  390. * Get hash code
  391. *
  392. * @return string Hash code
  393. */
  394. public function getHashCode()
  395. {
  396. return md5(
  397. $this->formula1 .
  398. $this->formula2 .
  399. $this->type = PHPExcel_Cell_DataValidation::TYPE_NONE .
  400. $this->errorStyle = PHPExcel_Cell_DataValidation::STYLE_STOP .
  401. $this->operator .
  402. ($this->allowBlank ? 't' : 'f') .
  403. ($this->showDropDown ? 't' : 'f') .
  404. ($this->showInputMessage ? 't' : 'f') .
  405. ($this->showErrorMessage ? 't' : 'f') .
  406. $this->errorTitle .
  407. $this->error .
  408. $this->promptTitle .
  409. $this->prompt .
  410. __CLASS__
  411. );
  412. }
  413. /**
  414. * Implement PHP __clone to create a deep clone, not just a shallow copy.
  415. */
  416. public function __clone()
  417. {
  418. $vars = get_object_vars($this);
  419. foreach ($vars as $key => $value) {
  420. if (is_object($value)) {
  421. $this->$key = clone $value;
  422. } else {
  423. $this->$key = $value;
  424. }
  425. }
  426. }
  427. }