PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.2.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.2.0
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Functions.php +584 -618 3.1.02.2.0 View file →
@@ -1,13 +1,39 @@
1 1 <?php
2 +/**
3 + * PHPExcel
4 + *
5 + * Copyright (c) 2006 - 2014 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 - 2014 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 + */
2 27
28 +
3 29 /** PHPExcel root directory */
4 30 if (!defined('PHPEXCEL_ROOT')) {
5 - /**
6 - * @ignore
7 - */
8 - define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
9 - require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
31 + /**
32 + * @ignore
33 + */
34 + define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
35 + require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
10 36 }
11 37
12 38
13 39 /** MAX_VALUE */
@@ -25,500 +51,446 @@
25 51
26 52 /**
27 53 * PHPExcel_Calculation_Functions
28 54 *
29 - * Copyright (c) 2006 - 2015 PHPExcel
30 - *
31 - * This library is free software; you can redistribute it and/or
32 - * modify it under the terms of the GNU Lesser General Public
33 - * License as published by the Free Software Foundation; either
34 - * version 2.1 of the License, or (at your option) any later version.
35 - *
36 - * This library is distributed in the hope that it will be useful,
37 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
38 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
39 - * Lesser General Public License for more details.
40 - *
41 - * You should have received a copy of the GNU Lesser General Public
42 - * License along with this library; if not, write to the Free Software
43 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
44 - *
45 - * @category PHPExcel
46 - * @package PHPExcel_Calculation
47 - * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
48 - * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
49 - * @version ##VERSION##, ##DATE##
55 + * @category PHPExcel
56 + * @package PHPExcel_Calculation
57 + * @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
50 58 */
51 -class PHPExcel_Calculation_Functions
52 -{
59 +class PHPExcel_Calculation_Functions {
53 60
54 - /** constants */
55 - const COMPATIBILITY_EXCEL = 'Excel';
56 - const COMPATIBILITY_GNUMERIC = 'Gnumeric';
57 - const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
61 + /** constants */
62 + const COMPATIBILITY_EXCEL = 'Excel';
63 + const COMPATIBILITY_GNUMERIC = 'Gnumeric';
64 + const COMPATIBILITY_OPENOFFICE = 'OpenOfficeCalc';
58 65
59 - const RETURNDATE_PHP_NUMERIC = 'P';
60 - const RETURNDATE_PHP_OBJECT = 'O';
61 - const RETURNDATE_EXCEL = 'E';
66 + const RETURNDATE_PHP_NUMERIC = 'P';
67 + const RETURNDATE_PHP_OBJECT = 'O';
68 + const RETURNDATE_EXCEL = 'E';
62 69
63 70
64 - /**
65 - * Compatibility mode to use for error checking and responses
66 - *
67 - * @access private
68 - * @var string
69 - */
70 - protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
71 + /**
72 + * Compatibility mode to use for error checking and responses
73 + *
74 + * @access private
75 + * @var string
76 + */
77 + protected static $compatibilityMode = self::COMPATIBILITY_EXCEL;
71 78
72 - /**
73 - * Data Type to use when returning date values
74 - *
75 - * @access private
76 - * @var string
77 - */
78 - protected static $returnDateType = self::RETURNDATE_EXCEL;
79 + /**
80 + * Data Type to use when returning date values
81 + *
82 + * @access private
83 + * @var string
84 + */
85 + protected static $ReturnDateType = self::RETURNDATE_EXCEL;
79 86
80 - /**
81 - * List of error codes
82 - *
83 - * @access private
84 - * @var array
85 - */
86 - protected static $errorCodes = array(
87 - 'null' => '#NULL!',
88 - 'divisionbyzero' => '#DIV/0!',
89 - 'value' => '#VALUE!',
90 - 'reference' => '#REF!',
91 - 'name' => '#NAME?',
92 - 'num' => '#NUM!',
93 - 'na' => '#N/A',
94 - 'gettingdata' => '#GETTING_DATA'
95 - );
87 + /**
88 + * List of error codes
89 + *
90 + * @access private
91 + * @var array
92 + */
93 + protected static $_errorCodes = array( 'null' => '#NULL!',
94 + 'divisionbyzero' => '#DIV/0!',
95 + 'value' => '#VALUE!',
96 + 'reference' => '#REF!',
97 + 'name' => '#NAME?',
98 + 'num' => '#NUM!',
99 + 'na' => '#N/A',
100 + 'gettingdata' => '#GETTING_DATA'
101 + );
96 102
97 103
98 - /**
99 - * Set the Compatibility Mode
100 - *
101 - * @access public
102 - * @category Function Configuration
103 - * @param string $compatibilityMode Compatibility Mode
104 - * Permitted values are:
105 - * PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
106 - * PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
107 - * PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
108 - * @return boolean (Success or Failure)
109 - */
110 - public static function setCompatibilityMode($compatibilityMode)
111 - {
112 - if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
113 - ($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
114 - ($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
115 - self::$compatibilityMode = $compatibilityMode;
116 - return true;
117 - }
118 - return false;
119 - }
104 + /**
105 + * Set the Compatibility Mode
106 + *
107 + * @access public
108 + * @category Function Configuration
109 + * @param string $compatibilityMode Compatibility Mode
110 + * Permitted values are:
111 + * PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
112 + * PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
113 + * PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
114 + * @return boolean (Success or Failure)
115 + */
116 + public static function setCompatibilityMode($compatibilityMode) {
117 + if (($compatibilityMode == self::COMPATIBILITY_EXCEL) ||
118 + ($compatibilityMode == self::COMPATIBILITY_GNUMERIC) ||
119 + ($compatibilityMode == self::COMPATIBILITY_OPENOFFICE)) {
120 + self::$compatibilityMode = $compatibilityMode;
121 + return True;
122 + }
123 + return False;
124 + } // function setCompatibilityMode()
120 125
121 126
122 - /**
123 - * Return the current Compatibility Mode
124 - *
125 - * @access public
126 - * @category Function Configuration
127 - * @return string Compatibility Mode
128 - * Possible Return values are:
129 - * PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
130 - * PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
131 - * PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
132 - */
133 - public static function getCompatibilityMode()
134 - {
135 - return self::$compatibilityMode;
136 - }
127 + /**
128 + * Return the current Compatibility Mode
129 + *
130 + * @access public
131 + * @category Function Configuration
132 + * @return string Compatibility Mode
133 + * Possible Return values are:
134 + * PHPExcel_Calculation_Functions::COMPATIBILITY_EXCEL 'Excel'
135 + * PHPExcel_Calculation_Functions::COMPATIBILITY_GNUMERIC 'Gnumeric'
136 + * PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc'
137 + */
138 + public static function getCompatibilityMode() {
139 + return self::$compatibilityMode;
140 + } // function getCompatibilityMode()
137 141
138 142
139 - /**
140 - * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
141 - *
142 - * @access public
143 - * @category Function Configuration
144 - * @param string $returnDateType Return Date Format
145 - * Permitted values are:
146 - * PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
147 - * PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
148 - * PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
149 - * @return boolean Success or failure
150 - */
151 - public static function setReturnDateType($returnDateType)
152 - {
153 - if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
154 - ($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
155 - ($returnDateType == self::RETURNDATE_EXCEL)) {
156 - self::$returnDateType = $returnDateType;
157 - return true;
158 - }
159 - return false;
160 - }
143 + /**
144 + * Set the Return Date Format used by functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
145 + *
146 + * @access public
147 + * @category Function Configuration
148 + * @param string $returnDateType Return Date Format
149 + * Permitted values are:
150 + * PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
151 + * PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
152 + * PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
153 + * @return boolean Success or failure
154 + */
155 + public static function setReturnDateType($returnDateType) {
156 + if (($returnDateType == self::RETURNDATE_PHP_NUMERIC) ||
157 + ($returnDateType == self::RETURNDATE_PHP_OBJECT) ||
158 + ($returnDateType == self::RETURNDATE_EXCEL)) {
159 + self::$ReturnDateType = $returnDateType;
160 + return True;
161 + }
162 + return False;
163 + } // function setReturnDateType()
161 164
162 165
163 - /**
164 - * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
165 - *
166 - * @access public
167 - * @category Function Configuration
168 - * @return string Return Date Format
169 - * Possible Return values are:
170 - * PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
171 - * PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
172 - * PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
173 - */
174 - public static function getReturnDateType()
175 - {
176 - return self::$returnDateType;
177 - }
166 + /**
167 + * Return the current Return Date Format for functions that return a date/time (Excel, PHP Serialized Numeric or PHP Object)
168 + *
169 + * @access public
170 + * @category Function Configuration
171 + * @return string Return Date Format
172 + * Possible Return values are:
173 + * PHPExcel_Calculation_Functions::RETURNDATE_PHP_NUMERIC 'P'
174 + * PHPExcel_Calculation_Functions::RETURNDATE_PHP_OBJECT 'O'
175 + * PHPExcel_Calculation_Functions::RETURNDATE_EXCEL 'E'
176 + */
177 + public static function getReturnDateType() {
178 + return self::$ReturnDateType;
179 + } // function getReturnDateType()
178 180
179 181
180 - /**
181 - * DUMMY
182 - *
183 - * @access public
184 - * @category Error Returns
185 - * @return string #Not Yet Implemented
186 - */
187 - public static function DUMMY()
188 - {
189 - return '#Not Yet Implemented';
190 - }
182 + /**
183 + * DUMMY
184 + *
185 + * @access public
186 + * @category Error Returns
187 + * @return string #Not Yet Implemented
188 + */
189 + public static function DUMMY() {
190 + return '#Not Yet Implemented';
191 + } // function DUMMY()
191 192
192 193
193 - /**
194 - * DIV0
195 - *
196 - * @access public
197 - * @category Error Returns
198 - * @return string #Not Yet Implemented
199 - */
200 - public static function DIV0()
201 - {
202 - return self::$errorCodes['divisionbyzero'];
203 - }
194 + /**
195 + * DIV0
196 + *
197 + * @access public
198 + * @category Error Returns
199 + * @return string #Not Yet Implemented
200 + */
201 + public static function DIV0() {
202 + return self::$_errorCodes['divisionbyzero'];
203 + } // function DIV0()
204 204
205 205
206 - /**
207 - * NA
208 - *
209 - * Excel Function:
210 - * =NA()
211 - *
212 - * Returns the error value #N/A
213 - * #N/A is the error value that means "no value is available."
214 - *
215 - * @access public
216 - * @category Logical Functions
217 - * @return string #N/A!
218 - */
219 - public static function NA()
220 - {
221 - return self::$errorCodes['na'];
222 - }
206 + /**
207 + * NA
208 + *
209 + * Excel Function:
210 + * =NA()
211 + *
212 + * Returns the error value #N/A
213 + * #N/A is the error value that means "no value is available."
214 + *
215 + * @access public
216 + * @category Logical Functions
217 + * @return string #N/A!
218 + */
219 + public static function NA() {
220 + return self::$_errorCodes['na'];
221 + } // function NA()
223 222
224 223
225 - /**
226 - * NaN
227 - *
228 - * Returns the error value #NUM!
229 - *
230 - * @access public
231 - * @category Error Returns
232 - * @return string #NUM!
233 - */
234 - public static function NaN()
235 - {
236 - return self::$errorCodes['num'];
237 - }
224 + /**
225 + * NaN
226 + *
227 + * Returns the error value #NUM!
228 + *
229 + * @access public
230 + * @category Error Returns
231 + * @return string #NUM!
232 + */
233 + public static function NaN() {
234 + return self::$_errorCodes['num'];
235 + } // function NaN()
238 236
239 237
240 - /**
241 - * NAME
242 - *
243 - * Returns the error value #NAME?
244 - *
245 - * @access public
246 - * @category Error Returns
247 - * @return string #NAME?
248 - */
249 - public static function NAME()
250 - {
251 - return self::$errorCodes['name'];
252 - }
238 + /**
239 + * NAME
240 + *
241 + * Returns the error value #NAME?
242 + *
243 + * @access public
244 + * @category Error Returns
245 + * @return string #NAME?
246 + */
247 + public static function NAME() {
248 + return self::$_errorCodes['name'];
249 + } // function NAME()
253 250
254 251
255 - /**
256 - * REF
257 - *
258 - * Returns the error value #REF!
259 - *
260 - * @access public
261 - * @category Error Returns
262 - * @return string #REF!
263 - */
264 - public static function REF()
265 - {
266 - return self::$errorCodes['reference'];
267 - }
252 + /**
253 + * REF
254 + *
255 + * Returns the error value #REF!
256 + *
257 + * @access public
258 + * @category Error Returns
259 + * @return string #REF!
260 + */
261 + public static function REF() {
262 + return self::$_errorCodes['reference'];
263 + } // function REF()
268 264
269 265
270 - /**
271 - * NULL
272 - *
273 - * Returns the error value #NULL!
274 - *
275 - * @access public
276 - * @category Error Returns
277 - * @return string #NULL!
278 - */
279 - public static function NULL()
280 - {
281 - return self::$errorCodes['null'];
282 - }
266 + /**
267 + * NULL
268 + *
269 + * Returns the error value #NULL!
270 + *
271 + * @access public
272 + * @category Error Returns
273 + * @return string #NULL!
274 + */
275 + public static function NULL() {
276 + return self::$_errorCodes['null'];
277 + } // function NULL()
283 278
284 279
285 - /**
286 - * VALUE
287 - *
288 - * Returns the error value #VALUE!
289 - *
290 - * @access public
291 - * @category Error Returns
292 - * @return string #VALUE!
293 - */
294 - public static function VALUE()
295 - {
296 - return self::$errorCodes['value'];
297 - }
280 + /**
281 + * VALUE
282 + *
283 + * Returns the error value #VALUE!
284 + *
285 + * @access public
286 + * @category Error Returns
287 + * @return string #VALUE!
288 + */
289 + public static function VALUE() {
290 + return self::$_errorCodes['value'];
291 + } // function VALUE()
298 292
299 293
300 - public static function isMatrixValue($idx)
301 - {
302 - return ((substr_count($idx, '.') <= 1) || (preg_match('/\.[A-Z]/', $idx) > 0));
303 - }
294 + public static function isMatrixValue($idx) {
295 + return ((substr_count($idx,'.') <= 1) || (preg_match('/\.[A-Z]/',$idx) > 0));
296 + }
304 297
305 298
306 - public static function isValue($idx)
307 - {
308 - return (substr_count($idx, '.') == 0);
309 - }
299 + public static function isValue($idx) {
300 + return (substr_count($idx,'.') == 0);
301 + }
310 302
311 303
312 - public static function isCellValue($idx)
313 - {
314 - return (substr_count($idx, '.') > 1);
315 - }
304 + public static function isCellValue($idx) {
305 + return (substr_count($idx,'.') > 1);
306 + }
316 307
317 308
318 - public static function ifCondition($condition)
319 - {
320 - $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
321 - if (!isset($condition{0})) {
322 - $condition = '=""';
323 - }
324 - if (!in_array($condition{0}, array('>', '<', '='))) {
325 - if (!is_numeric($condition)) {
326 - $condition = PHPExcel_Calculation::wrapResult(strtoupper($condition));
327 - }
328 - return '=' . $condition;
329 - } else {
330 - preg_match('/([<>=]+)(.*)/', $condition, $matches);
331 - list(, $operator, $operand) = $matches;
309 + public static function _ifCondition($condition) {
310 + $condition = PHPExcel_Calculation_Functions::flattenSingleValue($condition);
311 + if (!isset($condition{0}))
312 + $condition = '=""';
313 + if (!in_array($condition{0},array('>', '<', '='))) {
314 + if (!is_numeric($condition)) { $condition = PHPExcel_Calculation::_wrapResult(strtoupper($condition)); }
315 + return '='.$condition;
316 + } else {
317 + preg_match('/([<>=]+)(.*)/',$condition,$matches);
318 + list(,$operator,$operand) = $matches;
332 319
333 - if (!is_numeric($operand)) {
334 - $operand = str_replace('"', '""', $operand);
335 - $operand = PHPExcel_Calculation::wrapResult(strtoupper($operand));
336 - }
320 + if (!is_numeric($operand)) {
321 + $operand = str_replace('"', '""', $operand);
322 + $operand = PHPExcel_Calculation::_wrapResult(strtoupper($operand));
323 + }
337 324
338 - return $operator.$operand;
339 - }
340 - }
325 + return $operator.$operand;
326 + }
327 + } // function _ifCondition()
341 328
342 - /**
343 - * ERROR_TYPE
344 - *
345 - * @param mixed $value Value to check
346 - * @return boolean
347 - */
348 - public static function ERROR_TYPE($value = '')
349 - {
350 - $value = self::flattenSingleValue($value);
351 329
352 - $i = 1;
353 - foreach (self::$errorCodes as $errorCode) {
354 - if ($value === $errorCode) {
355 - return $i;
356 - }
357 - ++$i;
358 - }
359 - return self::NA();
360 - }
330 + /**
331 + * ERROR_TYPE
332 + *
333 + * @param mixed $value Value to check
334 + * @return boolean
335 + */
336 + public static function ERROR_TYPE($value = '') {
337 + $value = self::flattenSingleValue($value);
361 338
339 + $i = 1;
340 + foreach(self::$_errorCodes as $errorCode) {
341 + if ($value === $errorCode) {
342 + return $i;
343 + }
344 + ++$i;
345 + }
346 + return self::NA();
347 + } // function ERROR_TYPE()
362 348
363 - /**
364 - * IS_BLANK
365 - *
366 - * @param mixed $value Value to check
367 - * @return boolean
368 - */
369 - public static function IS_BLANK($value = null)
370 - {
371 - if (!is_null($value)) {
372 - $value = self::flattenSingleValue($value);
373 - }
374 349
375 - return is_null($value);
376 - }
350 + /**
351 + * IS_BLANK
352 + *
353 + * @param mixed $value Value to check
354 + * @return boolean
355 + */
356 + public static function IS_BLANK($value = NULL) {
357 + if (!is_null($value)) {
358 + $value = self::flattenSingleValue($value);
359 + }
377 360
361 + return is_null($value);
362 + } // function IS_BLANK()
378 363
379 - /**
380 - * IS_ERR
381 - *
382 - * @param mixed $value Value to check
383 - * @return boolean
384 - */
385 - public static function IS_ERR($value = '')
386 - {
387 - $value = self::flattenSingleValue($value);
388 364
389 - return self::IS_ERROR($value) && (!self::IS_NA($value));
390 - }
365 + /**
366 + * IS_ERR
367 + *
368 + * @param mixed $value Value to check
369 + * @return boolean
370 + */
371 + public static function IS_ERR($value = '') {
372 + $value = self::flattenSingleValue($value);
391 373
374 + return self::IS_ERROR($value) && (!self::IS_NA($value));
375 + } // function IS_ERR()
392 376
393 - /**
394 - * IS_ERROR
395 - *
396 - * @param mixed $value Value to check
397 - * @return boolean
398 - */
399 - public static function IS_ERROR($value = '')
400 - {
401 - $value = self::flattenSingleValue($value);
402 377
403 - if (!is_string($value)) {
404 - return false;
405 - }
406 - return in_array($value, array_values(self::$errorCodes));
407 - }
378 + /**
379 + * IS_ERROR
380 + *
381 + * @param mixed $value Value to check
382 + * @return boolean
383 + */
384 + public static function IS_ERROR($value = '') {
385 + $value = self::flattenSingleValue($value);
408 386
387 + if (!is_string($value))
388 + return false;
389 + return in_array($value, array_values(self::$_errorCodes));
390 + } // function IS_ERROR()
409 391
410 - /**
411 - * IS_NA
412 - *
413 - * @param mixed $value Value to check
414 - * @return boolean
415 - */
416 - public static function IS_NA($value = '')
417 - {
418 - $value = self::flattenSingleValue($value);
419 392
420 - return ($value === self::NA());
421 - }
393 + /**
394 + * IS_NA
395 + *
396 + * @param mixed $value Value to check
397 + * @return boolean
398 + */
399 + public static function IS_NA($value = '') {
400 + $value = self::flattenSingleValue($value);
422 401
402 + return ($value === self::NA());
403 + } // function IS_NA()
423 404
424 - /**
425 - * IS_EVEN
426 - *
427 - * @param mixed $value Value to check
428 - * @return boolean
429 - */
430 - public static function IS_EVEN($value = null)
431 - {
432 - $value = self::flattenSingleValue($value);
433 405
434 - if ($value === null) {
435 - return self::NAME();
436 - } elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
437 - return self::VALUE();
438 - }
406 + /**
407 + * IS_EVEN
408 + *
409 + * @param mixed $value Value to check
410 + * @return boolean
411 + */
412 + public static function IS_EVEN($value = NULL) {
413 + $value = self::flattenSingleValue($value);
439 414
440 - return ($value % 2 == 0);
441 - }
415 + if ($value === NULL)
416 + return self::NAME();
417 + if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
418 + return self::VALUE();
419 + return ($value % 2 == 0);
420 + } // function IS_EVEN()
442 421
443 422
444 - /**
445 - * IS_ODD
446 - *
447 - * @param mixed $value Value to check
448 - * @return boolean
449 - */
450 - public static function IS_ODD($value = null)
451 - {
452 - $value = self::flattenSingleValue($value);
423 + /**
424 + * IS_ODD
425 + *
426 + * @param mixed $value Value to check
427 + * @return boolean
428 + */
429 + public static function IS_ODD($value = NULL) {
430 + $value = self::flattenSingleValue($value);
453 431
454 - if ($value === null) {
455 - return self::NAME();
456 - } elseif ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value)))) {
457 - return self::VALUE();
458 - }
432 + if ($value === NULL)
433 + return self::NAME();
434 + if ((is_bool($value)) || ((is_string($value)) && (!is_numeric($value))))
435 + return self::VALUE();
436 + return (abs($value) % 2 == 1);
437 + } // function IS_ODD()
459 438
460 - return (abs($value) % 2 == 1);
461 - }
462 439
440 + /**
441 + * IS_NUMBER
442 + *
443 + * @param mixed $value Value to check
444 + * @return boolean
445 + */
446 + public static function IS_NUMBER($value = NULL) {
447 + $value = self::flattenSingleValue($value);
463 448
464 - /**
465 - * IS_NUMBER
466 - *
467 - * @param mixed $value Value to check
468 - * @return boolean
469 - */
470 - public static function IS_NUMBER($value = null)
471 - {
472 - $value = self::flattenSingleValue($value);
449 + if (is_string($value)) {
450 + return False;
451 + }
452 + return is_numeric($value);
453 + } // function IS_NUMBER()
473 454
474 - if (is_string($value)) {
475 - return false;
476 - }
477 - return is_numeric($value);
478 - }
479 455
456 + /**
457 + * IS_LOGICAL
458 + *
459 + * @param mixed $value Value to check
460 + * @return boolean
461 + */
462 + public static function IS_LOGICAL($value = NULL) {
463 + $value = self::flattenSingleValue($value);
480 464
481 - /**
482 - * IS_LOGICAL
483 - *
484 - * @param mixed $value Value to check
485 - * @return boolean
486 - */
487 - public static function IS_LOGICAL($value = null)
488 - {
489 - $value = self::flattenSingleValue($value);
465 + return is_bool($value);
466 + } // function IS_LOGICAL()
490 467
491 - return is_bool($value);
492 - }
493 468
469 + /**
470 + * IS_TEXT
471 + *
472 + * @param mixed $value Value to check
473 + * @return boolean
474 + */
475 + public static function IS_TEXT($value = NULL) {
476 + $value = self::flattenSingleValue($value);
494 477
495 - /**
496 - * IS_TEXT
497 - *
498 - * @param mixed $value Value to check
499 - * @return boolean
500 - */
501 - public static function IS_TEXT($value = null)
502 - {
503 - $value = self::flattenSingleValue($value);
478 + return (is_string($value) && !self::IS_ERROR($value));
479 + } // function IS_TEXT()
504 480
505 - return (is_string($value) && !self::IS_ERROR($value));
506 - }
507 481
482 + /**
483 + * IS_NONTEXT
484 + *
485 + * @param mixed $value Value to check
486 + * @return boolean
487 + */
488 + public static function IS_NONTEXT($value = NULL) {
489 + return !self::IS_TEXT($value);
490 + } // function IS_NONTEXT()
508 491
509 - /**
510 - * IS_NONTEXT
511 - *
512 - * @param mixed $value Value to check
513 - * @return boolean
514 - */
515 - public static function IS_NONTEXT($value = null)
516 - {
517 - return !self::IS_TEXT($value);
518 - }
519 492
520 -
521 493 /**
522 494 * VERSION
523 495 *
524 496 * @return string Version information
@@ -523,237 +495,231 @@
523 495 *
524 496 * @return string Version information
525 497 */
526 498 public static function VERSION() {
527 - return 'PHPExcel 1.8.2, 2018-11-22';
499 + return 'PHPExcel 1.8.1, 2015-04-30';
528 500 } // function VERSION()
529 501
530 502
531 - /**
532 - * N
533 - *
534 - * Returns a value converted to a number
535 - *
536 - * @param value The value you want converted
537 - * @return number N converts values listed in the following table
538 - * If value is or refers to N returns
539 - * A number That number
540 - * A date The serial number of that date
541 - * TRUE 1
542 - * FALSE 0
543 - * An error value The error value
544 - * Anything else 0
545 - */
546 - public static function N($value = null)
547 - {
548 - while (is_array($value)) {
549 - $value = array_shift($value);
550 - }
503 + /**
504 + * N
505 + *
506 + * Returns a value converted to a number
507 + *
508 + * @param value The value you want converted
509 + * @return number N converts values listed in the following table
510 + * If value is or refers to N returns
511 + * A number That number
512 + * A date The serial number of that date
513 + * TRUE 1
514 + * FALSE 0
515 + * An error value The error value
516 + * Anything else 0
517 + */
518 + public static function N($value = NULL) {
519 + while (is_array($value)) {
520 + $value = array_shift($value);
521 + }
551 522
552 - switch (gettype($value)) {
553 - case 'double':
554 - case 'float':
555 - case 'integer':
556 - return $value;
557 - case 'boolean':
558 - return (integer) $value;
559 - case 'string':
560 - // Errors
561 - if ((strlen($value) > 0) && ($value{0} == '#')) {
562 - return $value;
563 - }
564 - break;
565 - }
566 - return 0;
567 - }
523 + switch (gettype($value)) {
524 + case 'double' :
525 + case 'float' :
526 + case 'integer' :
527 + return $value;
528 + break;
529 + case 'boolean' :
530 + return (integer) $value;
531 + break;
532 + case 'string' :
533 + // Errors
534 + if ((strlen($value) > 0) && ($value{0} == '#')) {
535 + return $value;
536 + }
537 + break;
538 + }
539 + return 0;
540 + } // function N()
568 541
569 542
570 - /**
571 - * TYPE
572 - *
573 - * Returns a number that identifies the type of a value
574 - *
575 - * @param value The value you want tested
576 - * @return number N converts values listed in the following table
577 - * If value is or refers to N returns
578 - * A number 1
579 - * Text 2
580 - * Logical Value 4
581 - * An error value 16
582 - * Array or Matrix 64
583 - */
584 - public static function TYPE($value = null)
585 - {
586 - $value = self::flattenArrayIndexed($value);
587 - if (is_array($value) && (count($value) > 1)) {
588 - end($value);
589 - $a = key($value);
590 - // Range of cells is an error
591 - if (self::isCellValue($a)) {
592 - return 16;
593 - // Test for Matrix
594 - } elseif (self::isMatrixValue($a)) {
595 - return 64;
596 - }
597 - } elseif (empty($value)) {
598 - // Empty Cell
599 - return 1;
600 - }
601 - $value = self::flattenSingleValue($value);
543 + /**
544 + * TYPE
545 + *
546 + * Returns a number that identifies the type of a value
547 + *
548 + * @param value The value you want tested
549 + * @return number N converts values listed in the following table
550 + * If value is or refers to N returns
551 + * A number 1
552 + * Text 2
553 + * Logical Value 4
554 + * An error value 16
555 + * Array or Matrix 64
556 + */
557 + public static function TYPE($value = NULL) {
558 + $value = self::flattenArrayIndexed($value);
559 + if (is_array($value) && (count($value) > 1)) {
560 + $a = array_keys($value);
561 + $a = array_pop($a);
562 + // Range of cells is an error
563 + if (self::isCellValue($a)) {
564 + return 16;
565 + // Test for Matrix
566 + } elseif (self::isMatrixValue($a)) {
567 + return 64;
568 + }
569 + } elseif(empty($value)) {
570 + // Empty Cell
571 + return 1;
572 + }
573 + $value = self::flattenSingleValue($value);
602 574
603 - if (($value === null) || (is_float($value)) || (is_int($value))) {
604 - return 1;
605 - } elseif (is_bool($value)) {
606 - return 4;
607 - } elseif (is_array($value)) {
608 - return 64;
609 - } elseif (is_string($value)) {
610 - // Errors
611 - if ((strlen($value) > 0) && ($value{0} == '#')) {
612 - return 16;
613 - }
614 - return 2;
615 - }
616 - return 0;
617 - }
575 + if (($value === NULL) || (is_float($value)) || (is_int($value))) {
576 + return 1;
577 + } elseif(is_bool($value)) {
578 + return 4;
579 + } elseif(is_array($value)) {
580 + return 64;
581 + } elseif(is_string($value)) {
582 + // Errors
583 + if ((strlen($value) > 0) && ($value{0} == '#')) {
584 + return 16;
585 + }
586 + return 2;
587 + }
588 + return 0;
589 + } // function TYPE()
618 590
619 591
620 - /**
621 - * Convert a multi-dimensional array to a simple 1-dimensional array
622 - *
623 - * @param array $array Array to be flattened
624 - * @return array Flattened array
625 - */
626 - public static function flattenArray($array)
627 - {
628 - if (!is_array($array)) {
629 - return (array) $array;
630 - }
592 + /**
593 + * Convert a multi-dimensional array to a simple 1-dimensional array
594 + *
595 + * @param array $array Array to be flattened
596 + * @return array Flattened array
597 + */
598 + public static function flattenArray($array) {
599 + if (!is_array($array)) {
600 + return (array) $array;
601 + }
631 602
632 - $arrayValues = array();
633 - foreach ($array as $value) {
634 - if (is_array($value)) {
635 - foreach ($value as $val) {
636 - if (is_array($val)) {
637 - foreach ($val as $v) {
638 - $arrayValues[] = $v;
639 - }
640 - } else {
641 - $arrayValues[] = $val;
642 - }
643 - }
644 - } else {
645 - $arrayValues[] = $value;
646 - }
647 - }
603 + $arrayValues = array();
604 + foreach ($array as $value) {
605 + if (is_array($value)) {
606 + foreach ($value as $val) {
607 + if (is_array($val)) {
608 + foreach ($val as $v) {
609 + $arrayValues[] = $v;
610 + }
611 + } else {
612 + $arrayValues[] = $val;
613 + }
614 + }
615 + } else {
616 + $arrayValues[] = $value;
617 + }
618 + }
648 619
649 - return $arrayValues;
650 - }
620 + return $arrayValues;
621 + } // function flattenArray()
651 622
652 623
653 - /**
654 - * Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
655 - *
656 - * @param array $array Array to be flattened
657 - * @return array Flattened array
658 - */
659 - public static function flattenArrayIndexed($array)
660 - {
661 - if (!is_array($array)) {
662 - return (array) $array;
663 - }
624 + /**
625 + * Convert a multi-dimensional array to a simple 1-dimensional array, but retain an element of indexing
626 + *
627 + * @param array $array Array to be flattened
628 + * @return array Flattened array
629 + */
630 + public static function flattenArrayIndexed($array) {
631 + if (!is_array($array)) {
632 + return (array) $array;
633 + }
664 634
665 - $arrayValues = array();
666 - foreach ($array as $k1 => $value) {
667 - if (is_array($value)) {
668 - foreach ($value as $k2 => $val) {
669 - if (is_array($val)) {
670 - foreach ($val as $k3 => $v) {
671 - $arrayValues[$k1.'.'.$k2.'.'.$k3] = $v;
672 - }
673 - } else {
674 - $arrayValues[$k1.'.'.$k2] = $val;
675 - }
676 - }
677 - } else {
678 - $arrayValues[$k1] = $value;
679 - }
680 - }
635 + $arrayValues = array();
636 + foreach ($array as $k1 => $value) {
637 + if (is_array($value)) {
638 + foreach ($value as $k2 => $val) {
639 + if (is_array($val)) {
640 + foreach ($val as $k3 => $v) {
641 + $arrayValues[$k1.'.'.$k2.'.'.$k3] = $v;
642 + }
643 + } else {
644 + $arrayValues[$k1.'.'.$k2] = $val;
645 + }
646 + }
647 + } else {
648 + $arrayValues[$k1] = $value;
649 + }
650 + }
681 651
682 - return $arrayValues;
683 - }
652 + return $arrayValues;
653 + } // function flattenArrayIndexed()
684 654
685 655
686 - /**
687 - * Convert an array to a single scalar value by extracting the first element
688 - *
689 - * @param mixed $value Array or scalar value
690 - * @return mixed
691 - */
692 - public static function flattenSingleValue($value = '')
693 - {
694 - while (is_array($value)) {
695 - $value = array_pop($value);
696 - }
656 + /**
657 + * Convert an array to a single scalar value by extracting the first element
658 + *
659 + * @param mixed $value Array or scalar value
660 + * @return mixed
661 + */
662 + public static function flattenSingleValue($value = '') {
663 + while (is_array($value)) {
664 + $value = array_pop($value);
665 + }
697 666
698 - return $value;
699 - }
700 -}
667 + return $value;
668 + } // function flattenSingleValue()
701 669
670 +} // class PHPExcel_Calculation_Functions
702 671
672 +
703 673 //
704 -// There are a few mathematical functions that aren't available on all versions of PHP for all platforms
705 -// These functions aren't available in Windows implementations of PHP prior to version 5.3.0
706 -// So we test if they do exist for this version of PHP/operating platform; and if not we create them
674 +// There are a few mathematical functions that aren't available on all versions of PHP for all platforms
675 +// These functions aren't available in Windows implementations of PHP prior to version 5.3.0
676 +// So we test if they do exist for this version of PHP/operating platform; and if not we create them
707 677 //
708 678 if (!function_exists('acosh')) {
709 - function acosh($x)
710 - {
711 - return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
712 - } // function acosh()
679 + function acosh($x) {
680 + return 2 * log(sqrt(($x + 1) / 2) + sqrt(($x - 1) / 2));
681 + } // function acosh()
713 682 }
714 683
715 684 if (!function_exists('asinh')) {
716 - function asinh($x)
717 - {
718 - return log($x + sqrt(1 + $x * $x));
719 - } // function asinh()
685 + function asinh($x) {
686 + return log($x + sqrt(1 + $x * $x));
687 + } // function asinh()
720 688 }
721 689
722 690 if (!function_exists('atanh')) {
723 - function atanh($x)
724 - {
725 - return (log(1 + $x) - log(1 - $x)) / 2;
726 - } // function atanh()
691 + function atanh($x) {
692 + return (log(1 + $x) - log(1 - $x)) / 2;
693 + } // function atanh()
727 694 }
728 695
729 696
730 697 //
731 -// Strangely, PHP doesn't have a mb_str_replace multibyte function
732 -// As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set
698 +// Strangely, PHP doesn't have a mb_str_replace multibyte function
699 +// As we'll only ever use this function with UTF-8 characters, we can simply "hard-code" the character set
733 700 //
734 701 if ((!function_exists('mb_str_replace')) &&
735 - (function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
736 - function mb_str_replace($search, $replace, $subject)
737 - {
738 - if (is_array($subject)) {
739 - $ret = array();
740 - foreach ($subject as $key => $val) {
741 - $ret[$key] = mb_str_replace($search, $replace, $val);
742 - }
743 - return $ret;
744 - }
702 + (function_exists('mb_substr')) && (function_exists('mb_strlen')) && (function_exists('mb_strpos'))) {
703 + function mb_str_replace($search, $replace, $subject) {
704 + if(is_array($subject)) {
705 + $ret = array();
706 + foreach($subject as $key => $val) {
707 + $ret[$key] = mb_str_replace($search, $replace, $val);
708 + }
709 + return $ret;
710 + }
745 711
746 - foreach ((array) $search as $key => $s) {
747 - if ($s == '' && $s !== 0) {
748 - continue;
749 - }
750 - $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
751 - $pos = mb_strpos($subject, $s, 0, 'UTF-8');
752 - while ($pos !== false) {
753 - $subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
754 - $pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
755 - }
756 - }
757 - return $subject;
758 - }
712 + foreach((array) $search as $key => $s) {
713 + if($s == '' && $s !== 0) {
714 + continue;
715 + }
716 + $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : '');
717 + $pos = mb_strpos($subject, $s, 0, 'UTF-8');
718 + while($pos !== false) {
719 + $subject = mb_substr($subject, 0, $pos, 'UTF-8') . $r . mb_substr($subject, $pos + mb_strlen($s, 'UTF-8'), 65535, 'UTF-8');
720 + $pos = mb_strpos($subject, $s, $pos + mb_strlen($r, 'UTF-8'), 'UTF-8');
721 + }
722 + }
723 + return $subject;
724 + }
759 725 }