30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../');
38 require_once PHPEXCEL_ROOT .
'PHPExcel/Shared/JAMA/Matrix.php';
41 require_once PHPEXCEL_ROOT .
'PHPExcel/Calculation/Function.php';
44 require_once PHPEXCEL_ROOT .
'PHPExcel/Calculation/Functions.php';
122 private $_operators = array(
'+',
'-',
'*',
'/',
'^',
'&',
'%',
'_',
'>',
'<',
'=',
'>=',
'<=',
'<>');
131 private $_binaryOperators = array(
'+',
'-',
'*',
'/',
'^',
'&',
'>',
'<',
'=',
'>=',
'<=',
'<>');
149 'functionCall' =>
'abs',
150 'argumentCount' =>
'1'
153 'functionCall' =>
'PHPExcel_Calculation_Functions::ACCRINT',
154 'argumentCount' =>
'4-7'
157 'functionCall' =>
'PHPExcel_Calculation_Functions::ACCRINTM',
158 'argumentCount' =>
'3-5'
161 'functionCall' =>
'acos',
162 'argumentCount' =>
'1'
165 'functionCall' =>
'acosh',
166 'argumentCount' =>
'1'
169 'functionCall' =>
'PHPExcel_Calculation_Functions::CELL_ADDRESS',
170 'argumentCount' =>
'2-5'
173 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
174 'argumentCount' =>
'6,7'
177 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
178 'argumentCount' =>
'6,7'
181 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGICAL_AND',
182 'argumentCount' =>
'1+'
185 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
186 'argumentCount' =>
'1'
189 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
190 'argumentCount' =>
'1'
193 'functionCall' =>
'asin',
194 'argumentCount' =>
'1'
197 'functionCall' =>
'asinh',
198 'argumentCount' =>
'1'
201 'functionCall' =>
'atan',
202 'argumentCount' =>
'1'
205 'functionCall' =>
'PHPExcel_Calculation_Functions::REVERSE_ATAN2',
206 'argumentCount' =>
'2'
209 'functionCall' =>
'atanh',
210 'argumentCount' =>
'1'
213 'functionCall' =>
'PHPExcel_Calculation_Functions::AVEDEV',
214 'argumentCount' =>
'1+'
217 'functionCall' =>
'PHPExcel_Calculation_Functions::AVERAGE',
218 'argumentCount' =>
'1+'
221 'functionCall' =>
'PHPExcel_Calculation_Functions::AVERAGEA',
222 'argumentCount' =>
'1+'
225 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
226 'argumentCount' =>
'2,3'
229 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
230 'argumentCount' =>
'3+'
233 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
234 'argumentCount' =>
'1'
237 'functionCall' =>
'PHPExcel_Calculation_Functions::BESSELI',
238 'argumentCount' =>
'2'
241 'functionCall' =>
'PHPExcel_Calculation_Functions::BESSELJ',
242 'argumentCount' =>
'2'
245 'functionCall' =>
'PHPExcel_Calculation_Functions::BESSELK',
246 'argumentCount' =>
'2'
249 'functionCall' =>
'PHPExcel_Calculation_Functions::BESSELY',
250 'argumentCount' =>
'2'
253 'functionCall' =>
'PHPExcel_Calculation_Functions::BETADIST',
254 'argumentCount' =>
'3-5'
257 'functionCall' =>
'PHPExcel_Calculation_Functions::BETAINV',
258 'argumentCount' =>
'3-5'
261 'functionCall' =>
'PHPExcel_Calculation_Functions::BINTODEC',
262 'argumentCount' =>
'1'
265 'functionCall' =>
'PHPExcel_Calculation_Functions::BINTOHEX',
266 'argumentCount' =>
'1,2'
269 'functionCall' =>
'PHPExcel_Calculation_Functions::BINTOOCT',
270 'argumentCount' =>
'1,2'
273 'functionCall' =>
'PHPExcel_Calculation_Functions::BINOMDIST',
274 'argumentCount' =>
'4'
277 'functionCall' =>
'PHPExcel_Calculation_Functions::CEILING',
278 'argumentCount' =>
'2'
281 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
282 'argumentCount' =>
'1,2'
285 'functionCall' =>
'PHPExcel_Calculation_Functions::CHARACTER',
286 'argumentCount' =>
'1'
289 'functionCall' =>
'PHPExcel_Calculation_Functions::CHIDIST',
290 'argumentCount' =>
'2'
293 'functionCall' =>
'PHPExcel_Calculation_Functions::CHIINV',
294 'argumentCount' =>
'2'
297 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
298 'argumentCount' =>
'2'
301 'functionCall' =>
'PHPExcel_Calculation_Functions::CHOOSE',
302 'argumentCount' =>
'2+'
305 'functionCall' =>
'PHPExcel_Calculation_Functions::TRIMNONPRINTABLE',
306 'argumentCount' =>
'1'
309 'functionCall' =>
'PHPExcel_Calculation_Functions::ASCIICODE',
310 'argumentCount' =>
'1'
313 'functionCall' =>
'PHPExcel_Calculation_Functions::COLUMN',
314 'argumentCount' =>
'-1'
317 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
318 'argumentCount' =>
'1'
321 'functionCall' =>
'PHPExcel_Calculation_Functions::COMBIN',
322 'argumentCount' =>
'2'
325 'functionCall' =>
'PHPExcel_Calculation_Functions::COMPLEX',
326 'argumentCount' =>
'2,3'
329 'functionCall' =>
'PHPExcel_Calculation_Functions::CONCATENATE',
330 'argumentCount' =>
'1+'
333 'functionCall' =>
'PHPExcel_Calculation_Functions::CONFIDENCE',
334 'argumentCount' =>
'3'
337 'functionCall' =>
'PHPExcel_Calculation_Functions::CONVERTUOM',
338 'argumentCount' =>
'3'
341 'functionCall' =>
'PHPExcel_Calculation_Functions::CORREL',
342 'argumentCount' =>
'2'
345 'functionCall' =>
'cos',
346 'argumentCount' =>
'1'
349 'functionCall' =>
'cosh',
350 'argumentCount' =>
'1'
353 'functionCall' =>
'PHPExcel_Calculation_Functions::COUNT',
354 'argumentCount' =>
'1+'
357 'functionCall' =>
'PHPExcel_Calculation_Functions::COUNTA',
358 'argumentCount' =>
'1+'
361 'functionCall' =>
'PHPExcel_Calculation_Functions::COUNTBLANK',
362 'argumentCount' =>
'1'
365 'functionCall' =>
'PHPExcel_Calculation_Functions::COUNTIF',
366 'argumentCount' =>
'2'
369 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
370 'argumentCount' =>
'2'
373 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
374 'argumentCount' =>
'3,4'
377 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
378 'argumentCount' =>
'3,4'
381 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
382 'argumentCount' =>
'3,4'
385 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
386 'argumentCount' =>
'3,4'
389 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
390 'argumentCount' =>
'3,4'
393 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
394 'argumentCount' =>
'3,4'
397 'functionCall' =>
'PHPExcel_Calculation_Functions::COVAR',
398 'argumentCount' =>
'2'
401 'functionCall' =>
'PHPExcel_Calculation_Functions::CRITBINOM',
402 'argumentCount' =>
'3'
405 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
406 'argumentCount' =>
'?'
409 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
410 'argumentCount' =>
'?'
413 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
414 'argumentCount' =>
'?'
417 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
418 'argumentCount' =>
'?'
421 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
422 'argumentCount' =>
'?'
425 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
426 'argumentCount' =>
'?'
429 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
430 'argumentCount' =>
'?'
433 'functionCall' =>
'PHPExcel_Calculation_Functions::CUMIPMT',
434 'argumentCount' =>
'6'
437 'functionCall' =>
'PHPExcel_Calculation_Functions::CUMPRINC',
438 'argumentCount' =>
'6'
441 'functionCall' =>
'PHPExcel_Calculation_Functions::DATE',
442 'argumentCount' =>
'3'
445 'functionCall' =>
'PHPExcel_Calculation_Functions::DATEDIF',
446 'argumentCount' =>
'3'
449 'functionCall' =>
'PHPExcel_Calculation_Functions::DATEVALUE',
450 'argumentCount' =>
'1'
453 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
454 'argumentCount' =>
'?'
457 'functionCall' =>
'PHPExcel_Calculation_Functions::DAYOFMONTH',
458 'argumentCount' =>
'1'
461 'functionCall' =>
'PHPExcel_Calculation_Functions::DAYS360',
462 'argumentCount' =>
'2,3'
465 'functionCall' =>
'PHPExcel_Calculation_Functions::DB',
466 'argumentCount' =>
'4,5'
469 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
470 'argumentCount' =>
'?'
473 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
474 'argumentCount' =>
'?'
477 'functionCall' =>
'PHPExcel_Calculation_Functions::DDB',
478 'argumentCount' =>
'4,5'
481 'functionCall' =>
'PHPExcel_Calculation_Functions::DECTOBIN',
482 'argumentCount' =>
'1,2'
485 'functionCall' =>
'PHPExcel_Calculation_Functions::DECTOHEX',
486 'argumentCount' =>
'1,2'
489 'functionCall' =>
'PHPExcel_Calculation_Functions::DECTOOCT',
490 'argumentCount' =>
'1,2'
493 'functionCall' =>
'rad2deg',
494 'argumentCount' =>
'1'
497 'functionCall' =>
'PHPExcel_Calculation_Functions::DELTA',
498 'argumentCount' =>
'1,2'
501 'functionCall' =>
'PHPExcel_Calculation_Functions::DEVSQ',
502 'argumentCount' =>
'1+'
505 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
506 'argumentCount' =>
'?'
509 'functionCall' =>
'PHPExcel_Calculation_Functions::DISC',
510 'argumentCount' =>
'4,5'
513 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
514 'argumentCount' =>
'?'
517 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
518 'argumentCount' =>
'?'
521 'functionCall' =>
'PHPExcel_Calculation_Functions::DOLLAR',
522 'argumentCount' =>
'1,2'
525 'functionCall' =>
'PHPExcel_Calculation_Functions::DOLLARDE',
526 'argumentCount' =>
'2'
529 'functionCall' =>
'PHPExcel_Calculation_Functions::DOLLARFR',
530 'argumentCount' =>
'2'
533 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
534 'argumentCount' =>
'?'
537 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
538 'argumentCount' =>
'?'
541 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
542 'argumentCount' =>
'?'
545 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
546 'argumentCount' =>
'?'
549 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
550 'argumentCount' =>
'5,6'
553 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
554 'argumentCount' =>
'?'
557 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
558 'argumentCount' =>
'?'
561 'functionCall' =>
'PHPExcel_Calculation_Functions::EDATE',
562 'argumentCount' =>
'2'
565 'functionCall' =>
'PHPExcel_Calculation_Functions::EFFECT',
566 'argumentCount' =>
'2'
569 'functionCall' =>
'PHPExcel_Calculation_Functions::EOMONTH',
570 'argumentCount' =>
'2'
573 'functionCall' =>
'PHPExcel_Calculation_Functions::ERF',
574 'argumentCount' =>
'1,2'
577 'functionCall' =>
'PHPExcel_Calculation_Functions::ERFC',
578 'argumentCount' =>
'1'
581 'functionCall' =>
'PHPExcel_Calculation_Functions::ERROR_TYPE',
582 'argumentCount' =>
'1'
585 'functionCall' =>
'PHPExcel_Calculation_Functions::EVEN',
586 'argumentCount' =>
'1'
589 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
590 'argumentCount' =>
'2'
593 'functionCall' =>
'exp',
594 'argumentCount' =>
'1'
597 'functionCall' =>
'PHPExcel_Calculation_Functions::EXPONDIST',
598 'argumentCount' =>
'3'
601 'functionCall' =>
'PHPExcel_Calculation_Functions::FACT',
602 'argumentCount' =>
'1'
605 'functionCall' =>
'PHPExcel_Calculation_Functions::FACTDOUBLE',
606 'argumentCount' =>
'1'
609 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGICAL_FALSE',
610 'argumentCount' =>
'0'
613 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
614 'argumentCount' =>
'3'
617 'functionCall' =>
'PHPExcel_Calculation_Functions::SEARCHSENSITIVE',
618 'argumentCount' =>
'2,3'
621 'functionCall' =>
'PHPExcel_Calculation_Functions::SEARCHSENSITIVE',
622 'argumentCount' =>
'2,3'
625 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
626 'argumentCount' =>
'3'
629 'functionCall' =>
'PHPExcel_Calculation_Functions::FISHER',
630 'argumentCount' =>
'1'
633 'functionCall' =>
'PHPExcel_Calculation_Functions::FISHERINV',
634 'argumentCount' =>
'1'
637 'functionCall' =>
'PHPExcel_Calculation_Functions::FIXEDFORMAT',
638 'argumentCount' =>
'1-3'
641 'functionCall' =>
'PHPExcel_Calculation_Functions::FLOOR',
642 'argumentCount' =>
'2'
645 'functionCall' =>
'PHPExcel_Calculation_Functions::FORECAST',
646 'argumentCount' =>
'3'
649 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
650 'argumentCount' =>
'2'
653 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
654 'argumentCount' =>
'2'
657 'functionCall' =>
'PHPExcel_Calculation_Functions::FV',
658 'argumentCount' =>
'3-5'
661 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
662 'argumentCount' =>
'2'
665 'functionCall' =>
'PHPExcel_Calculation_Functions::GAMMADIST',
666 'argumentCount' =>
'4'
669 'functionCall' =>
'PHPExcel_Calculation_Functions::GAMMAINV',
670 'argumentCount' =>
'3'
673 'functionCall' =>
'PHPExcel_Calculation_Functions::GAMMALN',
674 'argumentCount' =>
'1'
677 'functionCall' =>
'PHPExcel_Calculation_Functions::GCD',
678 'argumentCount' =>
'1+'
681 'functionCall' =>
'PHPExcel_Calculation_Functions::GEOMEAN',
682 'argumentCount' =>
'1+'
685 'functionCall' =>
'PHPExcel_Calculation_Functions::GESTEP',
686 'argumentCount' =>
'1,2'
689 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
690 'argumentCount' =>
'2+'
693 'functionCall' =>
'PHPExcel_Calculation_Functions::GROWTH',
694 'argumentCount' =>
'1-4'
697 'functionCall' =>
'PHPExcel_Calculation_Functions::HARMEAN',
698 'argumentCount' =>
'1+'
701 'functionCall' =>
'PHPExcel_Calculation_Functions::HEXTOBIN',
702 'argumentCount' =>
'1,2'
705 'functionCall' =>
'PHPExcel_Calculation_Functions::HEXTODEC',
706 'argumentCount' =>
'1'
709 'functionCall' =>
'PHPExcel_Calculation_Functions::HEXTOOCT',
710 'argumentCount' =>
'1,2'
713 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
714 'argumentCount' =>
'3,4'
717 'functionCall' =>
'PHPExcel_Calculation_Functions::HOUROFDAY',
718 'argumentCount' =>
'1'
721 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
722 'argumentCount' =>
'1,2'
725 'functionCall' =>
'PHPExcel_Calculation_Functions::HYPGEOMDIST',
726 'argumentCount' =>
'4'
729 'functionCall' =>
'PHPExcel_Calculation_Functions::STATEMENT_IF',
730 'argumentCount' =>
'1-3'
733 'functionCall' =>
'PHPExcel_Calculation_Functions::STATEMENT_IFERROR',
734 'argumentCount' =>
'1'
737 'functionCall' =>
'PHPExcel_Calculation_Functions::IMABS',
738 'argumentCount' =>
'1'
741 'functionCall' =>
'PHPExcel_Calculation_Functions::IMAGINARY',
742 'argumentCount' =>
'1'
745 'functionCall' =>
'PHPExcel_Calculation_Functions::IMARGUMENT',
746 'argumentCount' =>
'1'
749 'functionCall' =>
'PHPExcel_Calculation_Functions::IMCONJUGATE',
750 'argumentCount' =>
'1'
753 'functionCall' =>
'PHPExcel_Calculation_Functions::IMCOS',
754 'argumentCount' =>
'1'
757 'functionCall' =>
'PHPExcel_Calculation_Functions::IMDIV',
758 'argumentCount' =>
'2'
761 'functionCall' =>
'PHPExcel_Calculation_Functions::IMEXP',
762 'argumentCount' =>
'1'
765 'functionCall' =>
'PHPExcel_Calculation_Functions::IMLN',
766 'argumentCount' =>
'1'
769 'functionCall' =>
'PHPExcel_Calculation_Functions::IMLOG10',
770 'argumentCount' =>
'1'
773 'functionCall' =>
'PHPExcel_Calculation_Functions::IMLOG2',
774 'argumentCount' =>
'1'
777 'functionCall' =>
'PHPExcel_Calculation_Functions::IMPOWER',
778 'argumentCount' =>
'2'
781 'functionCall' =>
'PHPExcel_Calculation_Functions::IMPRODUCT',
782 'argumentCount' =>
'1+'
785 'functionCall' =>
'PHPExcel_Calculation_Functions::IMREAL',
786 'argumentCount' =>
'1'
789 'functionCall' =>
'PHPExcel_Calculation_Functions::IMSIN',
790 'argumentCount' =>
'1'
793 'functionCall' =>
'PHPExcel_Calculation_Functions::IMSQRT',
794 'argumentCount' =>
'1'
797 'functionCall' =>
'PHPExcel_Calculation_Functions::IMSUB',
798 'argumentCount' =>
'2'
801 'functionCall' =>
'PHPExcel_Calculation_Functions::IMSUM',
802 'argumentCount' =>
'1+'
805 'functionCall' =>
'PHPExcel_Calculation_Functions::INDEX',
806 'argumentCount' =>
'1-4'
809 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
810 'argumentCount' =>
'1,2'
813 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
814 'argumentCount' =>
'1'
817 'functionCall' =>
'PHPExcel_Calculation_Functions::INTVALUE',
818 'argumentCount' =>
'1'
821 'functionCall' =>
'PHPExcel_Calculation_Functions::INTERCEPT',
822 'argumentCount' =>
'2'
825 'functionCall' =>
'PHPExcel_Calculation_Functions::INTRATE',
826 'argumentCount' =>
'4,5'
829 'functionCall' =>
'PHPExcel_Calculation_Functions::IPMT',
830 'argumentCount' =>
'4-6'
833 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
834 'argumentCount' =>
'1,2'
837 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_BLANK',
838 'argumentCount' =>
'1'
841 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ERR',
842 'argumentCount' =>
'1'
845 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ERROR',
846 'argumentCount' =>
'1'
849 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_EVEN',
850 'argumentCount' =>
'1'
853 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_LOGICAL',
854 'argumentCount' =>
'1'
857 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NA',
858 'argumentCount' =>
'1'
861 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NONTEXT',
862 'argumentCount' =>
'1'
865 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NUMBER',
866 'argumentCount' =>
'1'
869 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ODD',
870 'argumentCount' =>
'1'
873 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
874 'argumentCount' =>
'4'
877 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
878 'argumentCount' =>
'1'
881 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_TEXT',
882 'argumentCount' =>
'1'
885 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
886 'argumentCount' =>
'1'
889 'functionCall' =>
'PHPExcel_Calculation_Functions::KURT',
890 'argumentCount' =>
'1+'
893 'functionCall' =>
'PHPExcel_Calculation_Functions::LARGE',
894 'argumentCount' =>
'2'
897 'functionCall' =>
'PHPExcel_Calculation_Functions::LCM',
898 'argumentCount' =>
'1+'
901 'functionCall' =>
'PHPExcel_Calculation_Functions::LEFT',
902 'argumentCount' =>
'1,2'
905 'functionCall' =>
'PHPExcel_Calculation_Functions::LEFT',
906 'argumentCount' =>
'1,2'
909 'functionCall' =>
'PHPExcel_Calculation_Functions::STRINGLENGTH',
910 'argumentCount' =>
'1'
913 'functionCall' =>
'PHPExcel_Calculation_Functions::STRINGLENGTH',
914 'argumentCount' =>
'1'
917 'functionCall' =>
'PHPExcel_Calculation_Functions::LINEST',
918 'argumentCount' =>
'1-4'
921 'functionCall' =>
'log',
922 'argumentCount' =>
'1'
925 'functionCall' =>
'PHPExcel_Calculation_Functions::LOG_BASE',
926 'argumentCount' =>
'1,2'
929 'functionCall' =>
'log10',
930 'argumentCount' =>
'1'
933 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGEST',
934 'argumentCount' =>
'1-4'
937 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGINV',
938 'argumentCount' =>
'3'
941 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGNORMDIST',
942 'argumentCount' =>
'3'
945 'functionCall' =>
'PHPExcel_Calculation_Functions::LOOKUP',
946 'argumentCount' =>
'2,3'
949 'functionCall' =>
'PHPExcel_Calculation_Functions::LOWERCASE',
950 'argumentCount' =>
'1'
953 'functionCall' =>
'PHPExcel_Calculation_Functions::MATCH',
954 'argumentCount' =>
'2,3'
957 'functionCall' =>
'PHPExcel_Calculation_Functions::MAX',
958 'argumentCount' =>
'1+'
961 'functionCall' =>
'PHPExcel_Calculation_Functions::MAXA',
962 'argumentCount' =>
'1+'
965 'functionCall' =>
'PHPExcel_Calculation_Functions::MDETERM',
966 'argumentCount' =>
'1'
969 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
970 'argumentCount' =>
'5,6'
973 'functionCall' =>
'PHPExcel_Calculation_Functions::MEDIAN',
974 'argumentCount' =>
'1+'
977 'functionCall' =>
'PHPExcel_Calculation_Functions::MID',
978 'argumentCount' =>
'3'
981 'functionCall' =>
'PHPExcel_Calculation_Functions::MID',
982 'argumentCount' =>
'3'
985 'functionCall' =>
'PHPExcel_Calculation_Functions::MIN',
986 'argumentCount' =>
'1+'
989 'functionCall' =>
'PHPExcel_Calculation_Functions::MINA',
990 'argumentCount' =>
'1+'
993 'functionCall' =>
'PHPExcel_Calculation_Functions::MINUTEOFHOUR',
994 'argumentCount' =>
'1'
997 'functionCall' =>
'PHPExcel_Calculation_Functions::MINVERSE',
998 'argumentCount' =>
'1'
1001 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1002 'argumentCount' =>
'3'
1005 'functionCall' =>
'PHPExcel_Calculation_Functions::MMULT',
1006 'argumentCount' =>
'2'
1009 'functionCall' =>
'PHPExcel_Calculation_Functions::MOD',
1010 'argumentCount' =>
'2'
1013 'functionCall' =>
'PHPExcel_Calculation_Functions::MODE',
1014 'argumentCount' =>
'1+'
1017 'functionCall' =>
'PHPExcel_Calculation_Functions::MONTHOFYEAR',
1018 'argumentCount' =>
'1'
1021 'functionCall' =>
'PHPExcel_Calculation_Functions::MROUND',
1022 'argumentCount' =>
'2'
1025 'functionCall' =>
'PHPExcel_Calculation_Functions::MULTINOMIAL',
1026 'argumentCount' =>
'1+'
1029 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1030 'argumentCount' =>
'1'
1033 'functionCall' =>
'PHPExcel_Calculation_Functions::NA',
1034 'argumentCount' =>
'0'
1037 'functionCall' =>
'PHPExcel_Calculation_Functions::NEGBINOMDIST',
1038 'argumentCount' =>
'3'
1041 'functionCall' =>
'PHPExcel_Calculation_Functions::NETWORKDAYS',
1042 'argumentCount' =>
'2+'
1045 'functionCall' =>
'PHPExcel_Calculation_Functions::NOMINAL',
1046 'argumentCount' =>
'2'
1049 'functionCall' =>
'PHPExcel_Calculation_Functions::NORMDIST',
1050 'argumentCount' =>
'4'
1053 'functionCall' =>
'PHPExcel_Calculation_Functions::NORMINV',
1054 'argumentCount' =>
'3'
1057 'functionCall' =>
'PHPExcel_Calculation_Functions::NORMSDIST',
1058 'argumentCount' =>
'1'
1061 'functionCall' =>
'PHPExcel_Calculation_Functions::NORMSINV',
1062 'argumentCount' =>
'1'
1065 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGICAL_NOT',
1066 'argumentCount' =>
'1'
1069 'functionCall' =>
'PHPExcel_Calculation_Functions::DATETIMENOW',
1070 'argumentCount' =>
'0'
1073 'functionCall' =>
'PHPExcel_Calculation_Functions::NPER',
1074 'argumentCount' =>
'3-5'
1077 'functionCall' =>
'PHPExcel_Calculation_Functions::NPV',
1078 'argumentCount' =>
'2+'
1081 'functionCall' =>
'PHPExcel_Calculation_Functions::OCTTOBIN',
1082 'argumentCount' =>
'1,2'
1085 'functionCall' =>
'PHPExcel_Calculation_Functions::OCTTODEC',
1086 'argumentCount' =>
'1'
1089 'functionCall' =>
'PHPExcel_Calculation_Functions::OCTTOHEX',
1090 'argumentCount' =>
'1,2'
1093 'functionCall' =>
'PHPExcel_Calculation_Functions::ODD',
1094 'argumentCount' =>
'1'
1097 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1098 'argumentCount' =>
'8,9'
1101 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1102 'argumentCount' =>
'8,9'
1105 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1106 'argumentCount' =>
'7,8'
1109 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1110 'argumentCount' =>
'7,8'
1113 'functionCall' =>
'PHPExcel_Calculation_Functions::OFFSET',
1114 'argumentCount' =>
'3,5'
1117 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGICAL_OR',
1118 'argumentCount' =>
'1+'
1121 'functionCall' =>
'PHPExcel_Calculation_Functions::CORREL',
1122 'argumentCount' =>
'2'
1125 'functionCall' =>
'PHPExcel_Calculation_Functions::PERCENTILE',
1126 'argumentCount' =>
'2'
1129 'functionCall' =>
'PHPExcel_Calculation_Functions::PERCENTRANK',
1130 'argumentCount' =>
'2,3'
1133 'functionCall' =>
'PHPExcel_Calculation_Functions::PERMUT',
1134 'argumentCount' =>
'2'
1137 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1138 'argumentCount' =>
'1'
1141 'functionCall' =>
'pi',
1142 'argumentCount' =>
'0'
1145 'functionCall' =>
'PHPExcel_Calculation_Functions::PMT',
1146 'argumentCount' =>
'3-5'
1149 'functionCall' =>
'PHPExcel_Calculation_Functions::POISSON',
1150 'argumentCount' =>
'3'
1153 'functionCall' =>
'PHPExcel_Calculation_Functions::POWER',
1154 'argumentCount' =>
'2'
1157 'functionCall' =>
'PHPExcel_Calculation_Functions::PPMT',
1158 'argumentCount' =>
'4-6'
1161 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1162 'argumentCount' =>
'6,7'
1165 'functionCall' =>
'PHPExcel_Calculation_Functions::PRICEDISC',
1166 'argumentCount' =>
'4,5'
1169 'functionCall' =>
'PHPExcel_Calculation_Functions::PRICEMAT',
1170 'argumentCount' =>
'5,6'
1173 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1174 'argumentCount' =>
'3,4'
1177 'functionCall' =>
'PHPExcel_Calculation_Functions::PRODUCT',
1178 'argumentCount' =>
'1+'
1181 'functionCall' =>
'PHPExcel_Calculation_Functions::PROPERCASE',
1182 'argumentCount' =>
'1'
1185 'functionCall' =>
'PHPExcel_Calculation_Functions::PV',
1186 'argumentCount' =>
'3-5'
1189 'functionCall' =>
'PHPExcel_Calculation_Functions::QUARTILE',
1190 'argumentCount' =>
'2'
1193 'functionCall' =>
'PHPExcel_Calculation_Functions::QUOTIENT',
1194 'argumentCount' =>
'2'
1197 'functionCall' =>
'deg2rad',
1198 'argumentCount' =>
'1'
1201 'functionCall' =>
'PHPExcel_Calculation_Functions::RAND',
1202 'argumentCount' =>
'0'
1205 'functionCall' =>
'PHPExcel_Calculation_Functions::RAND',
1206 'argumentCount' =>
'2'
1209 'functionCall' =>
'PHPExcel_Calculation_Functions::RANK',
1210 'argumentCount' =>
'2,3'
1213 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1214 'argumentCount' =>
'3-6'
1217 'functionCall' =>
'PHPExcel_Calculation_Functions::RECEIVED',
1218 'argumentCount' =>
'4-5'
1221 'functionCall' =>
'PHPExcel_Calculation_Functions::REPLACE',
1222 'argumentCount' =>
'4'
1225 'functionCall' =>
'PHPExcel_Calculation_Functions::REPLACE',
1226 'argumentCount' =>
'4'
1229 'functionCall' =>
'str_repeat',
1230 'argumentCount' =>
'2'
1233 'functionCall' =>
'PHPExcel_Calculation_Functions::RIGHT',
1234 'argumentCount' =>
'1,2'
1237 'functionCall' =>
'PHPExcel_Calculation_Functions::RIGHT',
1238 'argumentCount' =>
'1,2'
1241 'functionCall' =>
'PHPExcel_Calculation_Functions::ROMAN',
1242 'argumentCount' =>
'1,2'
1245 'functionCall' =>
'round',
1246 'argumentCount' =>
'2'
1249 'functionCall' =>
'PHPExcel_Calculation_Functions::ROUNDDOWN',
1250 'argumentCount' =>
'2'
1253 'functionCall' =>
'PHPExcel_Calculation_Functions::ROUNDUP',
1254 'argumentCount' =>
'2'
1257 'functionCall' =>
'PHPExcel_Calculation_Functions::ROW',
1258 'argumentCount' =>
'-1'
1261 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1262 'argumentCount' =>
'1'
1265 'functionCall' =>
'PHPExcel_Calculation_Functions::RSQ',
1266 'argumentCount' =>
'2'
1269 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1270 'argumentCount' =>
'1+'
1273 'functionCall' =>
'PHPExcel_Calculation_Functions::SEARCHINSENSITIVE',
1274 'argumentCount' =>
'2,3'
1277 'functionCall' =>
'PHPExcel_Calculation_Functions::SEARCHINSENSITIVE',
1278 'argumentCount' =>
'2,3'
1281 'functionCall' =>
'PHPExcel_Calculation_Functions::SECONDOFMINUTE',
1282 'argumentCount' =>
'1'
1285 'functionCall' =>
'PHPExcel_Calculation_Functions::SERIESSUM',
1286 'argumentCount' =>
'4'
1289 'functionCall' =>
'PHPExcel_Calculation_Functions::SIGN',
1290 'argumentCount' =>
'1'
1293 'functionCall' =>
'sin',
1294 'argumentCount' =>
'1'
1297 'functionCall' =>
'sinh',
1298 'argumentCount' =>
'1'
1301 'functionCall' =>
'PHPExcel_Calculation_Functions::SKEW',
1302 'argumentCount' =>
'1+'
1305 'functionCall' =>
'PHPExcel_Calculation_Functions::SLN',
1306 'argumentCount' =>
'3'
1309 'functionCall' =>
'PHPExcel_Calculation_Functions::SLOPE',
1310 'argumentCount' =>
'2'
1313 'functionCall' =>
'PHPExcel_Calculation_Functions::SMALL',
1314 'argumentCount' =>
'2'
1317 'functionCall' =>
'sqrt',
1318 'argumentCount' =>
'1'
1321 'functionCall' =>
'PHPExcel_Calculation_Functions::SQRTPI',
1322 'argumentCount' =>
'1'
1325 'functionCall' =>
'PHPExcel_Calculation_Functions::STANDARDIZE',
1326 'argumentCount' =>
'3'
1329 'functionCall' =>
'PHPExcel_Calculation_Functions::STDEV',
1330 'argumentCount' =>
'1+'
1333 'functionCall' =>
'PHPExcel_Calculation_Functions::STDEVA',
1334 'argumentCount' =>
'1+'
1337 'functionCall' =>
'PHPExcel_Calculation_Functions::STDEVP',
1338 'argumentCount' =>
'1+'
1341 'functionCall' =>
'PHPExcel_Calculation_Functions::STDEVPA',
1342 'argumentCount' =>
'1+'
1345 'functionCall' =>
'PHPExcel_Calculation_Functions::STEYX',
1346 'argumentCount' =>
'2'
1349 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1350 'argumentCount' =>
'3,4'
1353 'functionCall' =>
'PHPExcel_Calculation_Functions::SUBTOTAL',
1354 'argumentCount' =>
'2+'
1357 'functionCall' =>
'PHPExcel_Calculation_Functions::SUM',
1358 'argumentCount' =>
'1+'
1361 'functionCall' =>
'PHPExcel_Calculation_Functions::SUMIF',
1362 'argumentCount' =>
'2,3'
1365 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1366 'argumentCount' =>
'?'
1369 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1370 'argumentCount' =>
'1+'
1373 'functionCall' =>
'PHPExcel_Calculation_Functions::SUMSQ',
1374 'argumentCount' =>
'1+'
1377 'functionCall' =>
'PHPExcel_Calculation_Functions::SUMX2MY2',
1378 'argumentCount' =>
'2'
1381 'functionCall' =>
'PHPExcel_Calculation_Functions::SUMX2PY2',
1382 'argumentCount' =>
'2'
1385 'functionCall' =>
'PHPExcel_Calculation_Functions::SUMXMY2',
1386 'argumentCount' =>
'2'
1389 'functionCall' =>
'PHPExcel_Calculation_Functions::SYD',
1390 'argumentCount' =>
'4'
1393 'functionCall' =>
'PHPExcel_Calculation_Functions::RETURNSTRING',
1394 'argumentCount' =>
'1'
1397 'functionCall' =>
'tan',
1398 'argumentCount' =>
'1'
1401 'functionCall' =>
'tanh',
1402 'argumentCount' =>
'1'
1405 'functionCall' =>
'PHPExcel_Calculation_Functions::TBILLEQ',
1406 'argumentCount' =>
'3'
1409 'functionCall' =>
'PHPExcel_Calculation_Functions::TBILLPRICE',
1410 'argumentCount' =>
'3'
1413 'functionCall' =>
'PHPExcel_Calculation_Functions::TBILLYIELD',
1414 'argumentCount' =>
'3'
1417 'functionCall' =>
'PHPExcel_Calculation_Functions::TDIST',
1418 'argumentCount' =>
'3'
1421 'functionCall' =>
'PHPExcel_Calculation_Functions::TEXTFORMAT',
1422 'argumentCount' =>
'2'
1425 'functionCall' =>
'PHPExcel_Calculation_Functions::TIME',
1426 'argumentCount' =>
'3'
1429 'functionCall' =>
'PHPExcel_Calculation_Functions::TIMEVALUE',
1430 'argumentCount' =>
'1'
1433 'functionCall' =>
'PHPExcel_Calculation_Functions::TINV',
1434 'argumentCount' =>
'2'
1437 'functionCall' =>
'PHPExcel_Calculation_Functions::DATENOW',
1438 'argumentCount' =>
'0'
1441 'functionCall' =>
'PHPExcel_Calculation_Functions::TRANSPOSE',
1442 'argumentCount' =>
'1'
1445 'functionCall' =>
'PHPExcel_Calculation_Functions::TREND',
1446 'argumentCount' =>
'1-4'
1449 'functionCall' =>
'PHPExcel_Calculation_Functions::TRIMSPACES',
1450 'argumentCount' =>
'1'
1453 'functionCall' =>
'PHPExcel_Calculation_Functions::TRIMMEAN',
1454 'argumentCount' =>
'2'
1457 'functionCall' =>
'PHPExcel_Calculation_Functions::LOGICAL_TRUE',
1458 'argumentCount' =>
'0'
1461 'functionCall' =>
'PHPExcel_Calculation_Functions::TRUNC',
1462 'argumentCount' =>
'1,2'
1465 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1466 'argumentCount' =>
'4'
1469 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1470 'argumentCount' =>
'1'
1473 'functionCall' =>
'PHPExcel_Calculation_Functions::UPPERCASE',
1474 'argumentCount' =>
'1'
1477 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1478 'argumentCount' =>
'2'
1481 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1482 'argumentCount' =>
'1'
1485 'functionCall' =>
'PHPExcel_Calculation_Functions::VARFunc',
1486 'argumentCount' =>
'1+'
1489 'functionCall' =>
'PHPExcel_Calculation_Functions::VARA',
1490 'argumentCount' =>
'1+'
1493 'functionCall' =>
'PHPExcel_Calculation_Functions::VARP',
1494 'argumentCount' =>
'1+'
1497 'functionCall' =>
'PHPExcel_Calculation_Functions::VARPA',
1498 'argumentCount' =>
'1+'
1501 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1502 'argumentCount' =>
'5-7'
1505 'functionCall' =>
'PHPExcel_Calculation_Functions::VERSION',
1506 'argumentCount' =>
'0'
1509 'functionCall' =>
'PHPExcel_Calculation_Functions::VLOOKUP',
1510 'argumentCount' =>
'3,4'
1513 'functionCall' =>
'PHPExcel_Calculation_Functions::DAYOFWEEK',
1514 'argumentCount' =>
'1,2'
1517 'functionCall' =>
'PHPExcel_Calculation_Functions::WEEKOFYEAR',
1518 'argumentCount' =>
'1,2'
1521 'functionCall' =>
'PHPExcel_Calculation_Functions::WEIBULL',
1522 'argumentCount' =>
'4'
1525 'functionCall' =>
'PHPExcel_Calculation_Functions::WORKDAY',
1526 'argumentCount' =>
'2+'
1529 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1530 'argumentCount' =>
'2,3'
1533 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1534 'argumentCount' =>
'3'
1537 'functionCall' =>
'PHPExcel_Calculation_Functions::YEAR',
1538 'argumentCount' =>
'1'
1541 'functionCall' =>
'PHPExcel_Calculation_Functions::YEARFRAC',
1542 'argumentCount' =>
'2,3'
1545 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1546 'argumentCount' =>
'6,7'
1549 'functionCall' =>
'PHPExcel_Calculation_Functions::YIELDDISC',
1550 'argumentCount' =>
'4,5'
1553 'functionCall' =>
'PHPExcel_Calculation_Functions::YIELDMAT',
1554 'argumentCount' =>
'5,6'
1557 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1558 'argumentCount' =>
'?'
1565 'MKMATRIX' => array(
'argumentCount' =>
'*',
1566 'functionCall' => array(
'self',
'_mkMatrix')
1580 if (!isset(self::$_instance) || is_null(self::$_instance)) {
1595 throw new Exception (
'Cloning a Singleton is not allowed!' );
1607 if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
1608 ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
1609 self::$returnArrayAsType = $returnType;
1645 $this->_calculationCacheEnabled = $pValue;
1670 $this->_calculationCache = array();
1690 $this->_calculationCacheExpirationTime = $pValue;
1703 if (is_string($value)) {
1705 if (preg_match(
'/^'.self::CALCULATION_REGEXP_ERROR.
'$/i', $value, $match)) {
1710 return '"'.$value.
'"';
1712 }
else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
1727 if (is_string($value)) {
1728 if ((strlen($value) > 0) && ($value{0} ==
'"') && (substr($value,-1) ==
'"')) {
1729 return substr($value,1,-1);
1732 }
else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
1767 $this->formulaError = null;
1768 $this->debugLog = array();
1769 $this->debugLogStack = array();
1773 if (is_null($pCell)) {
1776 $formula = $pCell->getValue();
1777 $cellID = $pCell->getCoordinate();
1794 $formula = trim($formula);
1795 if ($formula{0} !=
'=')
return array();
1796 $formula = trim(substr($formula,1));
1797 $formulaLength = strlen($formula);
1798 if ($formulaLength < 1)
return array();
1814 $this->formulaError = null;
1815 $this->debugLog = array();
1816 $this->debugLogStack = array();
1821 $this->_calculationCacheEnabled =
false;
1825 $this->_calculationCacheEnabled = $resetCache;
1846 $formula = trim($formula);
1847 if ($formula{0} !=
'=')
return self::_wrapResult($formula);
1848 $formula = trim(substr($formula,1));
1849 $formulaLength = strlen($formula);
1853 if (!is_null($cellID)) {
1854 if ($this->_calculationCacheEnabled) {
1857 if (isset($this->_calculationCache[$pCell->getParent()->getTitle()][$pCell->getCoordinate()])) {
1859 $this->
_writeDebug($cellID,
'Testing cache value');
1863 $this->
_writeDebug($cellID,
'Retrieving value from cache');
1865 $returnValue = $this->_calculationCache[$pCell->getParent()->getTitle()][$pCell->getCoordinate()][
'data'];
1867 if (is_array($returnValue)) {
1870 return $returnValue;
1873 $this->
_writeDebug($cellID,
'Cache value has expired');
1875 unset($this->_calculationCache[$pCell->getParent()->getTitle()][$pCell->getCoordinate()]);
1881 $this->debugLogStack[] = $cellID;
1884 array_pop($this->debugLogStack);
1887 if (!is_null($cellID)) {
1888 if ($this->_calculationCacheEnabled) {
1889 $this->_calculationCache[$pCell->getParent()->getTitle()][$pCell->getCoordinate()][
'time'] = (time() + microtime());
1890 $this->_calculationCache[$pCell->getParent()->getTitle()][$pCell->getCoordinate()][
'data'] = $cellValue;
1895 if (is_array($cellValue)) {
1912 if (!is_array($operand1)) {
1914 $operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1));
1916 }
elseif (!is_array($operand2)) {
1918 $operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2));
1925 }
elseif ($resize == 1) {
1938 foreach($matrix as $rowKey => $rowValue) {
1939 $matrix[$rowKey] = array_values($rowValue);
1941 return array_values($matrix);
1952 $matrixRows = count($matrix);
1954 foreach($matrix as $rowKey => $rowValue) {
1955 $colCount = count($rowValue);
1956 if ($colCount > $matrixColumns) {
1957 $matrixColumns = $colCount;
1959 $matrix[$rowKey] = array_values($rowValue);
1961 $matrix = array_values($matrix);
1962 return array($matrixRows,$matrixColumns);
1976 if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
1977 if ($matrix2Columns < $matrix1Columns) {
1978 for ($i = 0; $i < $matrix1Rows; ++$i) {
1979 for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
1980 unset($matrix1[$i][$j]);
1984 if ($matrix2Rows < $matrix1Rows) {
1985 for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) {
1986 unset($matrix1[$i]);
1991 if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
1992 if ($matrix1Columns < $matrix2Columns) {
1993 for ($i = 0; $i < $matrix2Rows; ++$i) {
1994 for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
1995 unset($matrix2[$i][$j]);
1999 if ($matrix1Rows < $matrix2Rows) {
2000 for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) {
2001 unset($matrix2[$i]);
2018 if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
2019 if ($matrix2Columns < $matrix1Columns) {
2020 for ($i = 0; $i < $matrix2Rows; ++$i) {
2021 $x = $matrix2[$i][$matrix2Columns-1];
2022 for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
2023 $matrix2[$i][$j] =
$x;
2027 if ($matrix2Rows < $matrix1Rows) {
2028 $x = $matrix2[$matrix2Rows-1];
2029 for ($i = 0; $i < $matrix1Rows; ++$i) {
2035 if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
2036 if ($matrix1Columns < $matrix2Columns) {
2037 for ($i = 0; $i < $matrix1Rows; ++$i) {
2038 $x = $matrix1[$i][$matrix1Columns-1];
2039 for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
2040 $matrix1[$i][$j] =
$x;
2044 if ($matrix1Rows < $matrix2Rows) {
2045 $x = $matrix1[$matrix1Rows-1];
2046 for ($i = 0; $i < $matrix2Rows; ++$i) {
2061 if (is_array($value)) {
2064 foreach($value as
$row) {
2065 if (is_array($row)) {
2066 if ($i > 0) { $retVal .=
'; '; }
2068 foreach($row as $column) {
2069 if ($j > 0) { $retVal .=
', '; }
2074 if ($i > 0) { $retVal .=
', '; }
2079 return '{ '.$retVal.
' }';
2080 }
elseif(is_bool($value)) {
2081 return ($value) ?
'TRUE' :
'FALSE';
2095 switch (gettype($value)) {
2098 $typeString =
'a floating point number';
2101 $typeString =
'an integer number';
2104 $typeString =
'a boolean';
2107 $typeString =
'a matrix';
2111 return 'an empty string';
2112 }
elseif ($value{0} ==
'#') {
2113 return 'a '.$value.
' error';
2115 $typeString =
'a string';
2119 return 'a null value';
2126 static $matrixReplaceFrom = array(
'{',
';',
'}');
2127 static $matrixReplaceTo = array(
'MKMATRIX(MKMATRIX(',
'),MKMATRIX(',
'))');
2130 if (strpos($formula,
'{') !==
false) {
2132 $openCount = $closeCount = 0;
2134 if (strpos($formula,
'"') !==
false) {
2137 $temp = explode(
'"',$formula);
2139 foreach($temp as &$value) {
2141 if (($i++ % 2) == 0) {
2142 $openCount += substr_count($value,
'{');
2143 $closeCount += substr_count($value,
'}');
2144 $value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value);
2149 $formula = implode(
'"',$temp);
2152 $openCount += substr_count($formula,
'{');
2153 $closeCount += substr_count($formula,
'}');
2154 $formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula);
2157 if ($openCount < $closeCount) {
2158 if ($openCount > 0) {
2163 }
elseif ($openCount > $closeCount) {
2164 if ($closeCount > 0) {
2177 return func_get_args();
2183 if (($formula = self::_convertMatrixReferences(trim($formula))) ===
false) {
2190 $operatorAssociativity = array(
'^' => 0,
2194 '>' => 0,
'<' => 0,
'=' => 0,
'>=' => 0,
'<=' => 0,
'<>' => 0
2198 $comparisonOperators = array(
'>',
'<',
'=',
'>=',
'<=',
'<>');
2203 $operatorPrecedence = array(
'_' => 6,
2209 '>' => 0,
'<' => 0,
'=' => 0,
'>=' => 0,
'<=' => 0,
'<>' => 0
2212 $regexpMatchString =
'/^('.self::CALCULATION_REGEXP_FUNCTION.
2213 '|'.self::CALCULATION_REGEXP_NUMBER.
2214 '|'.self::CALCULATION_REGEXP_STRING.
2215 '|'.self::CALCULATION_REGEXP_OPENBRACE.
2216 '|'.self::CALCULATION_REGEXP_CELLREF.
2217 '|'.self::CALCULATION_REGEXP_NAMEDRANGE.
2224 $expectingOperator =
false;
2226 $expectingOperand =
false;
2232 $opCharacter = $formula{$index};
2234 if ((in_array($opCharacter, $comparisonOperators)) && (strlen($formula) > $index) && (in_array($formula{$index+1}, $comparisonOperators))) {
2235 $opCharacter .= $formula{++$index};
2240 $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match);
2243 if ($opCharacter ==
'-' && !$expectingOperator) {
2247 }
elseif ($opCharacter ==
'%' && $expectingOperator) {
2251 }
elseif ($opCharacter ==
'+' && !$expectingOperator) {
2254 }
elseif (($opCharacter ==
'_') && (!$isOperandOrFunction)) {
2260 }
elseif ((in_array($opCharacter, $this->_operators) or $isOperandOrFunction) && $expectingOperator) {
2262 while($stack->count() > 0 &&
2263 ($o2 = $stack->last()) &&
2264 in_array($o2, $this->_operators) &&
2265 ($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2])) {
2266 $output[] = $stack->pop();
2268 $stack->push($opCharacter);
2270 $expectingOperator =
false;
2272 }
elseif ($opCharacter ==
')' && $expectingOperator) {
2274 $expectingOperand =
false;
2275 while (($o2 = $stack->pop()) !=
'(') {
2276 if (is_null($o2))
return $this->
_raiseFormulaError(
'Formula Error: Unexpected closing brace ")"');
2277 else $output[] = $o2;
2279 if (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $stack->last(2), $matches)) {
2280 $functionName = $matches[1];
2282 $argumentCount = $stack->pop();
2290 $output[] = $argumentCount;
2291 $output[] = $stack->pop();
2292 if (array_key_exists($functionName, $this->_controlFunctions)) {
2294 $expectedArgumentCount = $this->_controlFunctions[$functionName][
'argumentCount'];
2295 $functionCall = $this->_controlFunctions[$functionName][
'functionCall'];
2296 }
elseif (array_key_exists($functionName, $this->_PHPExcelFunctions)) {
2298 $expectedArgumentCount = $this->_PHPExcelFunctions[$functionName][
'argumentCount'];
2299 $functionCall = $this->_PHPExcelFunctions[$functionName][
'functionCall'];
2301 return $this->
_raiseFormulaError(
"Formula Error: Internal error, non-function on stack");
2304 $argumentCountError = False;
2305 if (is_numeric($expectedArgumentCount)) {
2306 if ($expectedArgumentCount < 0) {
2308 if ($argumentCount > abs($expectedArgumentCount)) {
2309 $argumentCountError = True;
2310 $expectedArgumentCountString =
'no more than '.abs($expectedArgumentCount);
2314 if ($argumentCount != $expectedArgumentCount) {
2315 $argumentCountError = True;
2316 $expectedArgumentCountString = $expectedArgumentCount;
2319 }
elseif ($expectedArgumentCount !=
'*') {
2320 $isOperandOrFunction = preg_match(
'/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch);
2323 switch ($argMatch[2]) {
2325 if ($argumentCount < $argMatch[1]) {
2326 $argumentCountError = True;
2327 $expectedArgumentCountString = $argMatch[1].
' or more ';
2331 if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
2332 $argumentCountError = True;
2333 $expectedArgumentCountString =
'between '.$argMatch[1].
' and '.$argMatch[3];
2337 if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
2338 $argumentCountError = True;
2339 $expectedArgumentCountString =
'either '.$argMatch[1].
' or '.$argMatch[3];
2344 if ($argumentCountError) {
2345 return $this->
_raiseFormulaError(
"Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString.
" expected");
2350 }
elseif ($opCharacter ==
',') {
2352 while (($o2 = $stack->pop()) !=
'(') {
2354 else $output[] = $o2;
2358 if (($expectingOperand) || (!$expectingOperator)) {
2359 $output[] = $this->_ExcelConstants[
'NULL'];
2362 if (!preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $stack->last(2), $matches))
2364 $stack->push($stack->pop()+1);
2366 $expectingOperator =
false;
2367 $expectingOperand =
true;
2370 }
elseif ($opCharacter ==
'(' && !$expectingOperator) {
2375 }
elseif ($isOperandOrFunction && !$expectingOperator) {
2376 $expectingOperator =
true;
2377 $expectingOperand =
false;
2379 $length = strlen($val);
2382 if (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $val, $matches)) {
2383 $val = preg_replace(
'/\s/',
'',$val);
2385 if (array_key_exists(strtoupper($matches[1]), $this->_controlFunctions) || array_key_exists(strtoupper($matches[1]), $this->_PHPExcelFunctions)) {
2386 $stack->push(strtoupper($val));
2387 $ax = preg_match(
'/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
2390 $expectingOperator =
true;
2393 $expectingOperator =
false;
2400 }
elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'$/i', $val, $matches)) {
2410 if ($opCharacter ==
'"') {
2412 $val = str_replace(
'""',
'"',$val);
2413 }
elseif (is_numeric($val)) {
2415 if ((strpos($val,
'.') !== False) || (stripos($val,
'e') !== False)) {
2417 $val = (float) $val;
2420 $val = (integer) $val;
2431 }
elseif ($opCharacter ==
')') {
2432 if ($expectingOperand) {
2433 $output[] = $this->_ExcelConstants[
'NULL'];
2434 $expectingOperand =
false;
2435 $expectingOperator = True;
2439 }
elseif (in_array($opCharacter, $this->_operators) && !$expectingOperator) {
2440 return $this->
_raiseFormulaError(
"Formula Error: Unexpected operator '$opCharacter'");
2445 if ($index == strlen($formula)) {
2448 if ((in_array($opCharacter, $this->_operators)) && ($opCharacter !=
'%')) {
2449 return $this->
_raiseFormulaError(
"Formula Error: Operator '$opCharacter' has no operands");
2455 while (substr($formula, $index, 1) ==
' ') {
2460 while (!is_null($opCharacter = $stack->pop())) {
2461 if ($opCharacter ==
'(')
return $this->
_raiseFormulaError(
"Formula Error: Expecting ')'");
2462 $output[] = $opCharacter;
2470 if ($tokens ==
false)
return false;
2475 foreach ($tokens as $token) {
2478 if (in_array($token, $this->_binaryOperators,
true)) {
2481 if (is_null($operand2 = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
2482 if (is_null($operand1 = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
2484 $this->
_writeDebug($cellID,
'Evaluating '.self::_showValue($operand1).
' '.$token.
' '.self::_showValue($operand2));
2516 if ((is_array($operand1)) || (is_array($operand2))) {
2521 $matrix =
new Matrix($operand1);
2523 $matrixResult = $matrix->concat($operand2);
2524 $result = $matrixResult->getArray();
2526 $this->
_writeDebug($cellID,
'JAMA Matrix Exception: '.$ex->getMessage());
2530 $result =
'"'.str_replace(
'""',
'"',self::_unwrapResult($operand1,
'"').self::_unwrapResult($operand2,
'"')).
'"';
2538 }
elseif (($token ===
"_") || ($token ===
"%")) {
2540 if (is_null($arg = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
2541 if ($token ===
"_") {
2543 $this->
_writeDebug($cellID,
'Evaluating Negation of '.self::_showValue($arg));
2547 $this->
_writeDebug($cellID,
'Evaluating Percentile of '.self::_showValue($arg));
2550 if (is_array($arg)) {
2553 $matrix1 =
new Matrix($arg);
2554 $matrixResult = $matrix1->arrayTimesEquals($multiplier);
2555 $result = $matrixResult->getArray();
2557 $this->
_writeDebug($cellID,
'JAMA Matrix Exception: '.$ex->getMessage());
2567 }
elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'$/i', $token, $matches)) {
2569 if (isset($matches[8])) {
2571 if (is_null($pCell)) {
2575 $cellRef = $matches[6].$matches[7].
':'.$matches[9].$matches[10];
2576 if ($matches[2] >
'') {
2578 $this->
_writeDebug($cellID,
'Evaluating Cell Range '.$cellRef.
' in worksheet '.$matches[2]);
2579 $cellValue = $this->
extractCellRange($cellRef, $pCell->getParent()->getParent()->getSheetByName($matches[2]),
false);
2580 $this->
_writeDebug($cellID,
'Evaluation Result for cells '.$cellRef.
' in worksheet '.$matches[2].
' is '.self::_showTypeDetails($cellValue));
2583 $this->
_writeDebug($cellID,
'Evaluating Cell Range '.$cellRef.
' in current worksheet');
2584 $cellValue = $this->
extractCellRange($cellRef, $pCell->getParent(),
false);
2585 $this->
_writeDebug($cellID,
'Evaluation Result for cells '.$cellRef.
' is '.self::_showTypeDetails($cellValue));
2590 if (is_null($pCell)) {
2594 $cellRef = $matches[6].$matches[7];
2595 if ($matches[2] >
'') {
2597 $this->
_writeDebug($cellID,
'Evaluating Cell '.$cellRef.
' in worksheet '.$matches[2]);
2598 if ($pCell->getParent()->cellExists($cellRef)) {
2599 $cellValue = $this->
extractCellRange($cellRef, $pCell->getParent()->getParent()->getSheetByName($matches[2]),
false);
2603 $this->
_writeDebug($cellID,
'Evaluation Result for cell '.$cellRef.
' in worksheet '.$matches[2].
' is '.self::_showTypeDetails($cellValue));
2606 $this->
_writeDebug($cellID,
'Evaluating Cell '.$cellRef.
' in current worksheet');
2607 if ($pCell->getParent()->cellExists($cellRef)) {
2608 $cellValue = $pCell->getParent()->getCell($cellRef)->getCalculatedValue(
false);
2612 $this->
_writeDebug($cellID,
'Evaluation Result for cell '.$cellRef.
' is '.self::_showTypeDetails($cellValue));
2616 $stack->push($cellValue);
2619 }
elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $token, $matches)) {
2621 $functionName = $matches[1];
2622 $argCount = $stack->pop();
2623 if ($functionName !=
'MKMATRIX') {
2624 $this->
_writeDebug($cellID,
'Evaluating Function '.$functionName.
'() with '.(($argCount == 0) ?
'no' : $argCount).
' argument'.(($argCount == 1) ?
'' :
's'));
2626 if ((array_key_exists($functionName, $this->_controlFunctions)) || (array_key_exists($functionName, $this->_PHPExcelFunctions))) {
2627 if (array_key_exists($functionName, $this->_controlFunctions)) {
2628 $functionCall = $this->_controlFunctions[$functionName][
'functionCall'];
2629 }
elseif (array_key_exists($functionName, $this->_PHPExcelFunctions)) {
2630 $functionCall = $this->_PHPExcelFunctions[$functionName][
'functionCall'];
2635 for ($i = $argCount; $i > 0; --$i) {
2636 $arg = $stack->pop();
2645 if ($functionName !=
'MKMATRIX') {
2646 $argArrayVals = array();
2647 foreach($args as &$arg) {
2652 $this->
_writeDebug($cellID,
'Evaluating '. $functionName.
'( '.implode(
', ',$argArrayVals).
' )');
2678 $result = call_user_func_array($functionCall,$args);
2680 if ($functionName !=
'MKMATRIX') {
2683 $stack->push(self::_wrapResult(
$result));
2688 if (array_key_exists(strtoupper($token), $this->_ExcelConstants)) {
2689 $excelConstant = strtoupper($token);
2691 $stack->push($this->_ExcelConstants[$excelConstant]);
2692 $this->
_writeDebug($cellID,
'Evaluating Constant '.$excelConstant.
' as '.self::_showTypeDetails($this->_ExcelConstants[$excelConstant]));
2693 }
elseif ((is_null($token)) || ($token ==
'') || (is_bool($token)) || (is_numeric($token)) || ($token{0} ==
'"') || ($token{0} ==
'#')) {
2695 $stack->push($token);
2697 }
elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_NAMEDRANGE.
'$/i', $token, $matches)) {
2699 $namedRange = $matches[6];
2701 $this->
_writeDebug($cellID,
'Evaluating Named Range '.$namedRange);
2703 $this->
_writeDebug($cellID,
'Evaluation Result for named range '.$namedRange.
' is '.self::_showTypeDetails($cellValue));
2704 $stack->push($cellValue);
2712 $output = $stack->pop();
2713 if ((is_array($output)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
2714 return array_unshift(array_unshift($output));
2722 if (is_string($operand)) {
2725 if ($operand >
'' && $operand{0} ==
'"') { $operand =
self::_unwrapResult($operand,
'"'); }
2727 if (!is_numeric($operand)) {
2729 if ($operand >
'' && $operand{0} ==
'#') {
2730 $stack->push($operand);
2731 $this->
_writeDebug($cellID,
'Evaluation Result is '.self::_showTypeDetails($operand));
2735 $stack->push(
'#VALUE!');
2736 $this->
_writeDebug($cellID,
'Evaluation Result is a '.self::_showTypeDetails(
'#VALUE!'));
2751 switch ($operation) {
2754 $result = ($operand1 > $operand2);
2758 $result = ($operand1 < $operand2);
2762 $result = ($operand1 == $operand2);
2766 $result = ($operand1 >= $operand2);
2770 $result = ($operand1 <= $operand2);
2774 $result = ($operand1 != $operand2);
2793 if ((is_array($operand1)) || (is_array($operand2))) {
2798 $matrix =
new Matrix($operand1);
2800 $matrixResult = $matrix->$matrixFunction($operand2);
2801 $result = $matrixResult->getArray();
2803 $this->
_writeDebug($cellID,
'JAMA Matrix Exception: '.$ex->getMessage());
2808 switch ($operation) {
2811 $result = $operand1+$operand2;
2815 $result = $operand1-$operand2;
2819 $result = $operand1*$operand2;
2823 if ($operand2 == 0) {
2825 $stack->push(
'#DIV/0!');
2826 $this->
_writeDebug($cellID,
'Evaluation Result is '.self::_showTypeDetails(
'#DIV/0!'));
2829 $result = $operand1/$operand2;
2834 $result = pow($operand1,$operand2);
2849 if ($this->writeDebugLog) {
2851 $prefix = implode(
' -> ',$this->debugLogStack).
' -> ';
2852 $this->debugLog[] = $prefix.$message;
2859 $this->formulaError = $errorMessage;
2860 if (!$this->suppressFormulaErrors)
throw new Exception($errorMessage);
2861 trigger_error($errorMessage, E_USER_ERROR);
2875 $returnValue = array ( );
2879 if (!is_null($pSheet)) {
2883 if (strpos ($pRange,
'!') !==
false) {
2886 $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
2888 $pRange = $worksheetReference[1];
2894 if (count($aReferences) == 1) {
2895 return $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
2899 foreach ($aReferences as $reference) {
2903 $returnValue[$currentCol][$currentRow] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
2908 return $returnValue;
2922 $returnValue = array ( );
2926 if (!is_null($pSheet)) {
2930 if (strpos ($pRange,
'!') !==
false) {
2933 $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
2935 $pRange = $worksheetReference[1];
2941 if (!is_null($namedRange)) {
2943 $pRange = $namedRange->getRange();
2945 if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
2946 if (!$namedRange->getLocalOnly()) {
2947 $pSheet = $namedRange->getWorksheet();
2949 return $returnValue;
2956 if (count($aReferences) == 1) {
2957 return $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
2961 foreach ($aReferences as $reference) {
2965 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
2969 $returnValue = array_values($returnValue);
2970 foreach($returnValue as &$rr) {
2971 $rr = array_values($rr);
2979 return $returnValue;
2990 $pFunction = strtoupper ($pFunction);
2991 if (isset ($this->_PHPExcelFunctions[$pFunction])) {
2992 return ($this->_PHPExcelFunctions[$pFunction][
'functionCall'] !=
'PHPExcel_Calculation_Functions::DUMMY');
3006 $returnValue = array();
3008 foreach($this->_PHPExcelFunctions as $functionName => $function) {
3009 if ($function[
'functionCall'] !=
'PHPExcel_Calculation_Functions::DUMMY') {
3012 $function[
'functionCall']
3018 return $returnValue;
3029 $returnValue = array();
3031 foreach ($this->_PHPExcelFunctions as $functionName => $function) {
3032 $returnValue[] = $functionName;
3036 return $returnValue;
3055 $this->_stack[$this->_count++] = $value;
3059 if ($this->_count > 0) {
3066 if ($this->_count-
$n < 0) {
3069 return $this->_stack[$this->_count-
$n];