File Source for DataValidation.php

PHPExcel_Cell

# Source for file DataValidation.php

Documentation is available at DataValidation.php

1. <?php
2. /**
3. * PHPExcel
4. *
5. * Copyright (c) 2006 - 2011 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_Cell
23. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
25. * @version 1.7.6, 2011-02-27
26. */
29. /**
30. * PHPExcel_Cell_DataValidation
31. *
32. * @category PHPExcel
33. * @package PHPExcel_Cell
34. * @copyright Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
35. */
36. class PHPExcel_Cell_DataValidation
37. {
38. /* Data validation types */
39. const TYPE_NONE = 'none';
40. const TYPE_CUSTOM = 'custom';
41. const TYPE_DATE = 'date';
42. const TYPE_DECIMAL = 'decimal';
43. const TYPE_LIST = 'list';
44. const TYPE_TEXTLENGTH = 'textLength';
45. const TYPE_TIME = 'time';
46. const TYPE_WHOLE = 'whole';
48. /* Data validation error styles */
49. const STYLE_STOP = 'stop';
50. const STYLE_WARNING = 'warning';
51. const STYLE_INFORMATION = 'information';
53. /* Data validation operators */
54. const OPERATOR_BETWEEN = 'between';
55. const OPERATOR_EQUAL = 'equal';
56. const OPERATOR_GREATERTHAN = 'greaterThan';
57. const OPERATOR_GREATERTHANOREQUAL = 'greaterThanOrEqual';
58. const OPERATOR_LESSTHAN = 'lessThan';
59. const OPERATOR_LESSTHANOREQUAL = 'lessThanOrEqual';
60. const OPERATOR_NOTBETWEEN = 'notBetween';
61. const OPERATOR_NOTEQUAL = 'notEqual';
63. /**
64. * Formula 1
65. *
66. * @var string
67. */
68. private $_formula1;
70. /**
71. * Formula 2
72. *
73. * @var string
74. */
75. private $_formula2;
77. /**
78. * Type
79. *
80. * @var string
81. */
82. private $_type = PHPExcel_Cell_DataValidation:: TYPE_NONE;
84. /**
85. * Error style
86. *
87. * @var string
88. */
89. private $_errorStyle = PHPExcel_Cell_DataValidation:: STYLE_STOP;
91. /**
92. * Operator
93. *
94. * @var string
95. */
96. private $_operator;
98. /**
99. * Allow Blank
100. *
101. * @var boolean
102. */
103. private $_allowBlank;
105. /**
106. * Show DropDown
107. *
108. * @var boolean
109. */
110. private $_showDropDown;
112. /**
113. * Show InputMessage
114. *
115. * @var boolean
116. */
117. private $_showInputMessage;
119. /**
120. * Show ErrorMessage
121. *
122. * @var boolean
123. */
124. private $_showErrorMessage;
126. /**
127. * Error title
128. *
129. * @var string
130. */
131. private $_errorTitle;
133. /**
134. * Error
135. *
136. * @var string
137. */
138. private $_error;
140. /**
141. * Prompt title
142. *
143. * @var string
144. */
145. private $_promptTitle;
147. /**
148. * Prompt
149. *
150. * @var string
151. */
152. private $_prompt;
154. /**
155. * Create a new PHPExcel_Cell_DataValidation
156. *
157. * @throws Exception
158. */
159. public function __construct()
160. {
161. // Initialise member variables
162. $this->_formula1 = '';
163. $this->_formula2 = '';
164. $this->_type = PHPExcel_Cell_DataValidation:: TYPE_NONE;
165. $this->_errorStyle = PHPExcel_Cell_DataValidation:: STYLE_STOP;
166. $this->_operator = '';
167. $this->_allowBlank = false;
168. $this->_showDropDown = false;
169. $this->_showInputMessage = false;
170. $this->_showErrorMessage = false;
171. $this->_errorTitle = '';
172. $this->_error = '';
173. $this->_promptTitle = '';
174. $this->_prompt = '';
175. }
177. /**
178. * Get Formula 1
179. *
180. * @return string
181. */
182. public function getFormula1() {
183. return $this->_formula1;
184. }
186. /**
187. * Set Formula 1
188. *
189. * @param string $value
190. * @return PHPExcel_Cell_DataValidation
191. */
192. public function setFormula1($value = '') {
193. $this->_formula1 = $value;
194. return $this;
195. }
197. /**
198. * Get Formula 2
199. *
200. * @return string
201. */
202. public function getFormula2() {
203. return $this->_formula2;
204. }
206. /**
207. * Set Formula 2
208. *
209. * @param string $value
210. * @return PHPExcel_Cell_DataValidation
211. */
212. public function setFormula2($value = '') {
213. $this->_formula2 = $value;
214. return $this;
215. }
217. /**
218. * Get Type
219. *
220. * @return string
221. */
222. public function getType() {
223. return $this->_type;
224. }
226. /**
227. * Set Type
228. *
229. * @param string $value
230. * @return PHPExcel_Cell_DataValidation
231. */
232. public function setType($value = PHPExcel_Cell_DataValidation:: TYPE_NONE) {
233. $this->_type = $value;
234. return $this;
235. }
237. /**
238. * Get Error style
239. *
240. * @return string
241. */
242. public function getErrorStyle() {
243. return $this->_errorStyle;
244. }
246. /**
247. * Set Error style
248. *
249. * @param string $value
250. * @return PHPExcel_Cell_DataValidation
251. */
252. public function setErrorStyle($value = PHPExcel_Cell_DataValidation:: STYLE_STOP) {
253. $this->_errorStyle = $value;
254. return $this;
255. }
257. /**
258. * Get Operator
259. *
260. * @return string
261. */
262. public function getOperator() {
263. return $this->_operator;
264. }
266. /**
267. * Set Operator
268. *
269. * @param string $value
270. * @return PHPExcel_Cell_DataValidation
271. */
272. public function setOperator($value = '') {
273. $this->_operator = $value;
274. return $this;
275. }
277. /**
278. * Get Allow Blank
279. *
280. * @return boolean
281. */
282. public function getAllowBlank() {
283. return $this->_allowBlank;
284. }
286. /**
287. * Set Allow Blank
288. *
289. * @param boolean $value
290. * @return PHPExcel_Cell_DataValidation
291. */
292. public function setAllowBlank($value = false) {
293. $this->_allowBlank = $value;
294. return $this;
295. }
297. /**
298. * Get Show DropDown
299. *
300. * @return boolean
301. */
302. public function getShowDropDown() {
303. return $this->_showDropDown;
304. }
306. /**
307. * Set Show DropDown
308. *
309. * @param boolean $value
310. * @return PHPExcel_Cell_DataValidation
311. */
312. public function setShowDropDown($value = false) {
313. $this->_showDropDown = $value;
314. return $this;
315. }
317. /**
318. * Get Show InputMessage
319. *
320. * @return boolean
321. */
322. public function getShowInputMessage() {
323. return $this->_showInputMessage;
324. }
326. /**
327. * Set Show InputMessage
328. *
329. * @param boolean $value
330. * @return PHPExcel_Cell_DataValidation
331. */
332. public function setShowInputMessage($value = false) {
333. $this->_showInputMessage = $value;
334. return $this;
335. }
337. /**
338. * Get Show ErrorMessage
339. *
340. * @return boolean
341. */
342. public function getShowErrorMessage() {
343. return $this->_showErrorMessage;
344. }
346. /**
347. * Set Show ErrorMessage
348. *
349. * @param boolean $value
350. * @return PHPExcel_Cell_DataValidation
351. */
352. public function setShowErrorMessage($value = false) {
353. $this->_showErrorMessage = $value;
354. return $this;
355. }
357. /**
358. * Get Error title
359. *
360. * @return string
361. */
362. public function getErrorTitle() {
363. return $this->_errorTitle;
364. }
366. /**
367. * Set Error title
368. *
369. * @param string $value
370. * @return PHPExcel_Cell_DataValidation
371. */
372. public function setErrorTitle($value = '') {
373. $this->_errorTitle = $value;
374. return $this;
375. }
377. /**
378. * Get Error
379. *
380. * @return string
381. */
382. public function getError() {
383. return $this->_error;
384. }
386. /**
387. * Set Error
388. *
389. * @param string $value
390. * @return PHPExcel_Cell_DataValidation
391. */
392. public function setError($value = '') {
393. $this->_error = $value;
394. return $this;
395. }
397. /**
398. * Get Prompt title
399. *
400. * @return string
401. */
402. public function getPromptTitle() {
403. return $this->_promptTitle;
404. }
406. /**
407. * Set Prompt title
408. *
409. * @param string $value
410. * @return PHPExcel_Cell_DataValidation
411. */
412. public function setPromptTitle($value = '') {
413. $this->_promptTitle = $value;
414. return $this;
415. }
417. /**
418. * Get Prompt
419. *
420. * @return string
421. */
422. public function getPrompt() {
423. return $this->_prompt;
424. }
426. /**
427. * Set Prompt
428. *
429. * @param string $value
430. * @return PHPExcel_Cell_DataValidation
431. */
432. public function setPrompt($value = '') {
433. $this->_prompt = $value;
434. return $this;
435. }
437. /**
438. * Get hash code
439. *
440. * @return string Hash code
441. */
442. public function getHashCode() {
443. return md5(
444. $this->_formula1
445. . $this->_formula2
446. . $this->_type = PHPExcel_Cell_DataValidation:: TYPE_NONE
447. . $this->_errorStyle = PHPExcel_Cell_DataValidation:: STYLE_STOP
448. . $this->_operator
449. . ($this->_allowBlank ? 't' : 'f')
450. . ($this->_showDropDown ? 't' : 'f')
451. . ($this->_showInputMessage ? 't' : 'f')
452. . ($this->_showErrorMessage ? 't' : 'f')
453. . $this->_errorTitle
454. . $this->_error
455. . $this->_promptTitle
456. . $this->_prompt
457. . __CLASS__
458. );
459. }
461. /**
462. * Implement PHP __clone to create a deep clone, not just a shallow copy.
463. */
464. public function __clone() {
465. $vars = get_object_vars($this);
466. foreach ($vars as $key => $value) {
467. if ( is_object($value)) {
468. $this->$key = clone $value;
469. } else {
470. $this->$key = $value;
471. }
472. }
473. }
474. }

Documentation generated on Sun, 27 Feb 2011 16:29:21 -0800 by phpDocumentor 1.4.3