30 if (!defined(
'PHPEXCEL_ROOT')) {
34 define(
'PHPEXCEL_ROOT', dirname(__FILE__) .
'/../');
35 require(PHPEXCEL_ROOT .
'PHPExcel/Autoloader.php');
39 if (!defined(
'CALCULATION_REGEXP_CELLREF')) {
41 if(defined(
'PREG_BAD_UTF8_ERROR')) {
43 define(
'CALCULATION_REGEXP_CELLREF',
'((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
45 define(
'CALCULATION_REGEXP_NAMEDRANGE',
'((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)');
48 define(
'CALCULATION_REGEXP_CELLREF',
'(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)');
50 define(
'CALCULATION_REGEXP_NAMEDRANGE',
'(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)');
133 private static $_operators = array(
'+' =>
true,
'-' =>
true,
'*' =>
true,
'/' =>
true,
134 '^' =>
true,
'&' =>
true,
'%' =>
false,
'~' =>
false,
135 '>' =>
true,
'<' =>
true,
'=' =>
true,
'>=' =>
true,
136 '<=' =>
true,
'<>' =>
true,
'|' =>
true,
':' =>
true
147 '^' =>
true,
'&' =>
true,
'>' =>
true,
'<' =>
true,
148 '=' =>
true,
'>=' =>
true,
'<=' =>
true,
'<>' =>
true,
149 '|' =>
true,
':' =>
true
241 'functionCall' =>
'abs',
242 'argumentCount' =>
'1'
245 'functionCall' =>
'PHPExcel_Calculation_Financial::ACCRINT',
246 'argumentCount' =>
'4-7'
249 'functionCall' =>
'PHPExcel_Calculation_Financial::ACCRINTM',
250 'argumentCount' =>
'3-5'
253 'functionCall' =>
'acos',
254 'argumentCount' =>
'1'
257 'functionCall' =>
'acosh',
258 'argumentCount' =>
'1'
261 'functionCall' =>
'PHPExcel_Calculation_LookupRef::CELL_ADDRESS',
262 'argumentCount' =>
'2-5'
265 'functionCall' =>
'PHPExcel_Calculation_Financial::AMORDEGRC',
266 'argumentCount' =>
'6,7'
269 'functionCall' =>
'PHPExcel_Calculation_Financial::AMORLINC',
270 'argumentCount' =>
'6,7'
273 'functionCall' =>
'PHPExcel_Calculation_Logical::LOGICAL_AND',
274 'argumentCount' =>
'1+'
277 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
278 'argumentCount' =>
'1'
281 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
282 'argumentCount' =>
'1'
285 'functionCall' =>
'asin',
286 'argumentCount' =>
'1'
289 'functionCall' =>
'asinh',
290 'argumentCount' =>
'1'
293 'functionCall' =>
'atan',
294 'argumentCount' =>
'1'
297 'functionCall' =>
'PHPExcel_Calculation_MathTrig::ATAN2',
298 'argumentCount' =>
'2'
301 'functionCall' =>
'atanh',
302 'argumentCount' =>
'1'
305 'functionCall' =>
'PHPExcel_Calculation_Statistical::AVEDEV',
306 'argumentCount' =>
'1+'
309 'functionCall' =>
'PHPExcel_Calculation_Statistical::AVERAGE',
310 'argumentCount' =>
'1+'
313 'functionCall' =>
'PHPExcel_Calculation_Statistical::AVERAGEA',
314 'argumentCount' =>
'1+'
317 'functionCall' =>
'PHPExcel_Calculation_Statistical::AVERAGEIF',
318 'argumentCount' =>
'2,3'
321 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
322 'argumentCount' =>
'3+'
325 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
326 'argumentCount' =>
'1'
329 'functionCall' =>
'PHPExcel_Calculation_Engineering::BESSELI',
330 'argumentCount' =>
'2'
333 'functionCall' =>
'PHPExcel_Calculation_Engineering::BESSELJ',
334 'argumentCount' =>
'2'
337 'functionCall' =>
'PHPExcel_Calculation_Engineering::BESSELK',
338 'argumentCount' =>
'2'
341 'functionCall' =>
'PHPExcel_Calculation_Engineering::BESSELY',
342 'argumentCount' =>
'2'
345 'functionCall' =>
'PHPExcel_Calculation_Statistical::BETADIST',
346 'argumentCount' =>
'3-5'
349 'functionCall' =>
'PHPExcel_Calculation_Statistical::BETAINV',
350 'argumentCount' =>
'3-5'
353 'functionCall' =>
'PHPExcel_Calculation_Engineering::BINTODEC',
354 'argumentCount' =>
'1'
357 'functionCall' =>
'PHPExcel_Calculation_Engineering::BINTOHEX',
358 'argumentCount' =>
'1,2'
361 'functionCall' =>
'PHPExcel_Calculation_Engineering::BINTOOCT',
362 'argumentCount' =>
'1,2'
365 'functionCall' =>
'PHPExcel_Calculation_Statistical::BINOMDIST',
366 'argumentCount' =>
'4'
369 'functionCall' =>
'PHPExcel_Calculation_MathTrig::CEILING',
370 'argumentCount' =>
'2'
373 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
374 'argumentCount' =>
'1,2'
377 'functionCall' =>
'PHPExcel_Calculation_TextData::CHARACTER',
378 'argumentCount' =>
'1'
381 'functionCall' =>
'PHPExcel_Calculation_Statistical::CHIDIST',
382 'argumentCount' =>
'2'
385 'functionCall' =>
'PHPExcel_Calculation_Statistical::CHIINV',
386 'argumentCount' =>
'2'
389 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
390 'argumentCount' =>
'2'
393 'functionCall' =>
'PHPExcel_Calculation_LookupRef::CHOOSE',
394 'argumentCount' =>
'2+'
397 'functionCall' =>
'PHPExcel_Calculation_TextData::TRIMNONPRINTABLE',
398 'argumentCount' =>
'1'
401 'functionCall' =>
'PHPExcel_Calculation_TextData::ASCIICODE',
402 'argumentCount' =>
'1'
405 'functionCall' =>
'PHPExcel_Calculation_LookupRef::COLUMN',
406 'argumentCount' =>
'-1',
407 'passByReference' => array(
true)
410 'functionCall' =>
'PHPExcel_Calculation_LookupRef::COLUMNS',
411 'argumentCount' =>
'1'
414 'functionCall' =>
'PHPExcel_Calculation_MathTrig::COMBIN',
415 'argumentCount' =>
'2'
418 'functionCall' =>
'PHPExcel_Calculation_Engineering::COMPLEX',
419 'argumentCount' =>
'2,3'
422 'functionCall' =>
'PHPExcel_Calculation_TextData::CONCATENATE',
423 'argumentCount' =>
'1+'
426 'functionCall' =>
'PHPExcel_Calculation_Statistical::CONFIDENCE',
427 'argumentCount' =>
'3'
430 'functionCall' =>
'PHPExcel_Calculation_Engineering::CONVERTUOM',
431 'argumentCount' =>
'3'
434 'functionCall' =>
'PHPExcel_Calculation_Statistical::CORREL',
435 'argumentCount' =>
'2'
438 'functionCall' =>
'cos',
439 'argumentCount' =>
'1'
442 'functionCall' =>
'cosh',
443 'argumentCount' =>
'1'
446 'functionCall' =>
'PHPExcel_Calculation_Statistical::COUNT',
447 'argumentCount' =>
'1+'
450 'functionCall' =>
'PHPExcel_Calculation_Statistical::COUNTA',
451 'argumentCount' =>
'1+'
454 'functionCall' =>
'PHPExcel_Calculation_Statistical::COUNTBLANK',
455 'argumentCount' =>
'1'
458 'functionCall' =>
'PHPExcel_Calculation_Statistical::COUNTIF',
459 'argumentCount' =>
'2'
462 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
463 'argumentCount' =>
'2'
466 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPDAYBS',
467 'argumentCount' =>
'3,4'
470 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPDAYS',
471 'argumentCount' =>
'3,4'
474 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPDAYSNC',
475 'argumentCount' =>
'3,4'
478 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPNCD',
479 'argumentCount' =>
'3,4'
482 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPNUM',
483 'argumentCount' =>
'3,4'
486 'functionCall' =>
'PHPExcel_Calculation_Financial::COUPPCD',
487 'argumentCount' =>
'3,4'
490 'functionCall' =>
'PHPExcel_Calculation_Statistical::COVAR',
491 'argumentCount' =>
'2'
494 'functionCall' =>
'PHPExcel_Calculation_Statistical::CRITBINOM',
495 'argumentCount' =>
'3'
498 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
499 'argumentCount' =>
'?'
502 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
503 'argumentCount' =>
'?'
506 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
507 'argumentCount' =>
'?'
510 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
511 'argumentCount' =>
'?'
514 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
515 'argumentCount' =>
'?'
518 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
519 'argumentCount' =>
'?'
522 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
523 'argumentCount' =>
'?'
526 'functionCall' =>
'PHPExcel_Calculation_Financial::CUMIPMT',
527 'argumentCount' =>
'6'
530 'functionCall' =>
'PHPExcel_Calculation_Financial::CUMPRINC',
531 'argumentCount' =>
'6'
534 'functionCall' =>
'PHPExcel_Calculation_DateTime::DATE',
535 'argumentCount' =>
'3'
538 'functionCall' =>
'PHPExcel_Calculation_DateTime::DATEDIF',
539 'argumentCount' =>
'2,3'
542 'functionCall' =>
'PHPExcel_Calculation_DateTime::DATEVALUE',
543 'argumentCount' =>
'1'
546 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
547 'argumentCount' =>
'3'
550 'functionCall' =>
'PHPExcel_Calculation_DateTime::DAYOFMONTH',
551 'argumentCount' =>
'1'
554 'functionCall' =>
'PHPExcel_Calculation_DateTime::DAYS360',
555 'argumentCount' =>
'2,3'
558 'functionCall' =>
'PHPExcel_Calculation_Financial::DB',
559 'argumentCount' =>
'4,5'
562 'functionCall' =>
'PHPExcel_Calculation_Database::DCOUNT',
563 'argumentCount' =>
'3'
566 'functionCall' =>
'PHPExcel_Calculation_Database::DCOUNTA',
567 'argumentCount' =>
'3'
570 'functionCall' =>
'PHPExcel_Calculation_Financial::DDB',
571 'argumentCount' =>
'4,5'
574 'functionCall' =>
'PHPExcel_Calculation_Engineering::DECTOBIN',
575 'argumentCount' =>
'1,2'
578 'functionCall' =>
'PHPExcel_Calculation_Engineering::DECTOHEX',
579 'argumentCount' =>
'1,2'
582 'functionCall' =>
'PHPExcel_Calculation_Engineering::DECTOOCT',
583 'argumentCount' =>
'1,2'
586 'functionCall' =>
'rad2deg',
587 'argumentCount' =>
'1'
590 'functionCall' =>
'PHPExcel_Calculation_Engineering::DELTA',
591 'argumentCount' =>
'1,2'
594 'functionCall' =>
'PHPExcel_Calculation_Statistical::DEVSQ',
595 'argumentCount' =>
'1+'
598 'functionCall' =>
'PHPExcel_Calculation_Database::DGET',
599 'argumentCount' =>
'3'
602 'functionCall' =>
'PHPExcel_Calculation_Financial::DISC',
603 'argumentCount' =>
'4,5'
606 'functionCall' =>
'PHPExcel_Calculation_Database::DMAX',
607 'argumentCount' =>
'3'
610 'functionCall' =>
'PHPExcel_Calculation_Database::DMIN',
611 'argumentCount' =>
'3'
614 'functionCall' =>
'PHPExcel_Calculation_TextData::DOLLAR',
615 'argumentCount' =>
'1,2'
618 'functionCall' =>
'PHPExcel_Calculation_Financial::DOLLARDE',
619 'argumentCount' =>
'2'
622 'functionCall' =>
'PHPExcel_Calculation_Financial::DOLLARFR',
623 'argumentCount' =>
'2'
626 'functionCall' =>
'PHPExcel_Calculation_Database::DPRODUCT',
627 'argumentCount' =>
'3'
630 'functionCall' =>
'PHPExcel_Calculation_Database::DSTDEV',
631 'argumentCount' =>
'3'
634 'functionCall' =>
'PHPExcel_Calculation_Database::DSTDEVP',
635 'argumentCount' =>
'3'
638 'functionCall' =>
'PHPExcel_Calculation_Database::DSUM',
639 'argumentCount' =>
'3'
642 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
643 'argumentCount' =>
'5,6'
646 'functionCall' =>
'PHPExcel_Calculation_Database::DVAR',
647 'argumentCount' =>
'3'
650 'functionCall' =>
'PHPExcel_Calculation_Database::DVARP',
651 'argumentCount' =>
'3'
654 'functionCall' =>
'PHPExcel_Calculation_DateTime::EDATE',
655 'argumentCount' =>
'2'
658 'functionCall' =>
'PHPExcel_Calculation_Financial::EFFECT',
659 'argumentCount' =>
'2'
662 'functionCall' =>
'PHPExcel_Calculation_DateTime::EOMONTH',
663 'argumentCount' =>
'2'
666 'functionCall' =>
'PHPExcel_Calculation_Engineering::ERF',
667 'argumentCount' =>
'1,2'
670 'functionCall' =>
'PHPExcel_Calculation_Engineering::ERFC',
671 'argumentCount' =>
'1'
674 'functionCall' =>
'PHPExcel_Calculation_Functions::ERROR_TYPE',
675 'argumentCount' =>
'1'
678 'functionCall' =>
'PHPExcel_Calculation_MathTrig::EVEN',
679 'argumentCount' =>
'1'
682 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
683 'argumentCount' =>
'2'
686 'functionCall' =>
'exp',
687 'argumentCount' =>
'1'
690 'functionCall' =>
'PHPExcel_Calculation_Statistical::EXPONDIST',
691 'argumentCount' =>
'3'
694 'functionCall' =>
'PHPExcel_Calculation_MathTrig::FACT',
695 'argumentCount' =>
'1'
698 'functionCall' =>
'PHPExcel_Calculation_MathTrig::FACTDOUBLE',
699 'argumentCount' =>
'1'
702 'functionCall' =>
'PHPExcel_Calculation_Logical::FALSE',
703 'argumentCount' =>
'0'
706 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
707 'argumentCount' =>
'3'
710 'functionCall' =>
'PHPExcel_Calculation_TextData::SEARCHSENSITIVE',
711 'argumentCount' =>
'2,3'
714 'functionCall' =>
'PHPExcel_Calculation_TextData::SEARCHSENSITIVE',
715 'argumentCount' =>
'2,3'
718 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
719 'argumentCount' =>
'3'
722 'functionCall' =>
'PHPExcel_Calculation_Statistical::FISHER',
723 'argumentCount' =>
'1'
726 'functionCall' =>
'PHPExcel_Calculation_Statistical::FISHERINV',
727 'argumentCount' =>
'1'
730 'functionCall' =>
'PHPExcel_Calculation_TextData::FIXEDFORMAT',
731 'argumentCount' =>
'1-3'
734 'functionCall' =>
'PHPExcel_Calculation_MathTrig::FLOOR',
735 'argumentCount' =>
'2'
738 'functionCall' =>
'PHPExcel_Calculation_Statistical::FORECAST',
739 'argumentCount' =>
'3'
742 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
743 'argumentCount' =>
'2'
746 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
747 'argumentCount' =>
'2'
750 'functionCall' =>
'PHPExcel_Calculation_Financial::FV',
751 'argumentCount' =>
'3-5'
754 'functionCall' =>
'PHPExcel_Calculation_Financial::FVSCHEDULE',
755 'argumentCount' =>
'2'
758 'functionCall' =>
'PHPExcel_Calculation_Statistical::GAMMADIST',
759 'argumentCount' =>
'4'
762 'functionCall' =>
'PHPExcel_Calculation_Statistical::GAMMAINV',
763 'argumentCount' =>
'3'
766 'functionCall' =>
'PHPExcel_Calculation_Statistical::GAMMALN',
767 'argumentCount' =>
'1'
770 'functionCall' =>
'PHPExcel_Calculation_MathTrig::GCD',
771 'argumentCount' =>
'1+'
774 'functionCall' =>
'PHPExcel_Calculation_Statistical::GEOMEAN',
775 'argumentCount' =>
'1+'
778 'functionCall' =>
'PHPExcel_Calculation_Engineering::GESTEP',
779 'argumentCount' =>
'1,2'
782 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
783 'argumentCount' =>
'2+'
786 'functionCall' =>
'PHPExcel_Calculation_Statistical::GROWTH',
787 'argumentCount' =>
'1-4'
790 'functionCall' =>
'PHPExcel_Calculation_Statistical::HARMEAN',
791 'argumentCount' =>
'1+'
794 'functionCall' =>
'PHPExcel_Calculation_Engineering::HEXTOBIN',
795 'argumentCount' =>
'1,2'
798 'functionCall' =>
'PHPExcel_Calculation_Engineering::HEXTODEC',
799 'argumentCount' =>
'1'
802 'functionCall' =>
'PHPExcel_Calculation_Engineering::HEXTOOCT',
803 'argumentCount' =>
'1,2'
806 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
807 'argumentCount' =>
'3,4'
810 'functionCall' =>
'PHPExcel_Calculation_DateTime::HOUROFDAY',
811 'argumentCount' =>
'1'
814 'functionCall' =>
'PHPExcel_Calculation_LookupRef::HYPERLINK',
815 'argumentCount' =>
'1,2',
816 'passCellReference'=>
true
819 'functionCall' =>
'PHPExcel_Calculation_Statistical::HYPGEOMDIST',
820 'argumentCount' =>
'4'
823 'functionCall' =>
'PHPExcel_Calculation_Logical::STATEMENT_IF',
824 'argumentCount' =>
'1-3'
827 'functionCall' =>
'PHPExcel_Calculation_Logical::IFERROR',
828 'argumentCount' =>
'2'
831 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMABS',
832 'argumentCount' =>
'1'
835 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMAGINARY',
836 'argumentCount' =>
'1'
839 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMARGUMENT',
840 'argumentCount' =>
'1'
843 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMCONJUGATE',
844 'argumentCount' =>
'1'
847 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMCOS',
848 'argumentCount' =>
'1'
851 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMDIV',
852 'argumentCount' =>
'2'
855 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMEXP',
856 'argumentCount' =>
'1'
859 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMLN',
860 'argumentCount' =>
'1'
863 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMLOG10',
864 'argumentCount' =>
'1'
867 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMLOG2',
868 'argumentCount' =>
'1'
871 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMPOWER',
872 'argumentCount' =>
'2'
875 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMPRODUCT',
876 'argumentCount' =>
'1+'
879 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMREAL',
880 'argumentCount' =>
'1'
883 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMSIN',
884 'argumentCount' =>
'1'
887 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMSQRT',
888 'argumentCount' =>
'1'
891 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMSUB',
892 'argumentCount' =>
'2'
895 'functionCall' =>
'PHPExcel_Calculation_Engineering::IMSUM',
896 'argumentCount' =>
'1+'
899 'functionCall' =>
'PHPExcel_Calculation_LookupRef::INDEX',
900 'argumentCount' =>
'1-4'
903 'functionCall' =>
'PHPExcel_Calculation_LookupRef::INDIRECT',
904 'argumentCount' =>
'1,2',
905 'passCellReference'=>
true
908 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
909 'argumentCount' =>
'1'
912 'functionCall' =>
'PHPExcel_Calculation_MathTrig::INT',
913 'argumentCount' =>
'1'
916 'functionCall' =>
'PHPExcel_Calculation_Statistical::INTERCEPT',
917 'argumentCount' =>
'2'
920 'functionCall' =>
'PHPExcel_Calculation_Financial::INTRATE',
921 'argumentCount' =>
'4,5'
924 'functionCall' =>
'PHPExcel_Calculation_Financial::IPMT',
925 'argumentCount' =>
'4-6'
928 'functionCall' =>
'PHPExcel_Calculation_Financial::IRR',
929 'argumentCount' =>
'1,2'
932 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_BLANK',
933 'argumentCount' =>
'1'
936 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ERR',
937 'argumentCount' =>
'1'
940 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ERROR',
941 'argumentCount' =>
'1'
944 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_EVEN',
945 'argumentCount' =>
'1'
948 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_LOGICAL',
949 'argumentCount' =>
'1'
952 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NA',
953 'argumentCount' =>
'1'
956 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NONTEXT',
957 'argumentCount' =>
'1'
960 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_NUMBER',
961 'argumentCount' =>
'1'
964 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_ODD',
965 'argumentCount' =>
'1'
968 'functionCall' =>
'PHPExcel_Calculation_Financial::ISPMT',
969 'argumentCount' =>
'4'
972 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
973 'argumentCount' =>
'1'
976 'functionCall' =>
'PHPExcel_Calculation_Functions::IS_TEXT',
977 'argumentCount' =>
'1'
980 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
981 'argumentCount' =>
'1'
984 'functionCall' =>
'PHPExcel_Calculation_Statistical::KURT',
985 'argumentCount' =>
'1+'
988 'functionCall' =>
'PHPExcel_Calculation_Statistical::LARGE',
989 'argumentCount' =>
'2'
992 'functionCall' =>
'PHPExcel_Calculation_MathTrig::LCM',
993 'argumentCount' =>
'1+'
996 'functionCall' =>
'PHPExcel_Calculation_TextData::LEFT',
997 'argumentCount' =>
'1,2'
1000 'functionCall' =>
'PHPExcel_Calculation_TextData::LEFT',
1001 'argumentCount' =>
'1,2'
1004 'functionCall' =>
'PHPExcel_Calculation_TextData::STRINGLENGTH',
1005 'argumentCount' =>
'1'
1008 'functionCall' =>
'PHPExcel_Calculation_TextData::STRINGLENGTH',
1009 'argumentCount' =>
'1'
1012 'functionCall' =>
'PHPExcel_Calculation_Statistical::LINEST',
1013 'argumentCount' =>
'1-4'
1016 'functionCall' =>
'log',
1017 'argumentCount' =>
'1'
1020 'functionCall' =>
'PHPExcel_Calculation_MathTrig::LOG_BASE',
1021 'argumentCount' =>
'1,2'
1024 'functionCall' =>
'log10',
1025 'argumentCount' =>
'1'
1028 'functionCall' =>
'PHPExcel_Calculation_Statistical::LOGEST',
1029 'argumentCount' =>
'1-4'
1032 'functionCall' =>
'PHPExcel_Calculation_Statistical::LOGINV',
1033 'argumentCount' =>
'3'
1036 'functionCall' =>
'PHPExcel_Calculation_Statistical::LOGNORMDIST',
1037 'argumentCount' =>
'3'
1040 'functionCall' =>
'PHPExcel_Calculation_LookupRef::LOOKUP',
1041 'argumentCount' =>
'2,3'
1044 'functionCall' =>
'PHPExcel_Calculation_TextData::LOWERCASE',
1045 'argumentCount' =>
'1'
1048 'functionCall' =>
'PHPExcel_Calculation_LookupRef::MATCH',
1049 'argumentCount' =>
'2,3'
1052 'functionCall' =>
'PHPExcel_Calculation_Statistical::MAX',
1053 'argumentCount' =>
'1+'
1056 'functionCall' =>
'PHPExcel_Calculation_Statistical::MAXA',
1057 'argumentCount' =>
'1+'
1060 'functionCall' =>
'PHPExcel_Calculation_Statistical::MAXIF',
1061 'argumentCount' =>
'2+'
1064 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MDETERM',
1065 'argumentCount' =>
'1'
1068 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1069 'argumentCount' =>
'5,6'
1072 'functionCall' =>
'PHPExcel_Calculation_Statistical::MEDIAN',
1073 'argumentCount' =>
'1+'
1076 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1077 'argumentCount' =>
'2+'
1080 'functionCall' =>
'PHPExcel_Calculation_TextData::MID',
1081 'argumentCount' =>
'3'
1084 'functionCall' =>
'PHPExcel_Calculation_TextData::MID',
1085 'argumentCount' =>
'3'
1088 'functionCall' =>
'PHPExcel_Calculation_Statistical::MIN',
1089 'argumentCount' =>
'1+'
1092 'functionCall' =>
'PHPExcel_Calculation_Statistical::MINA',
1093 'argumentCount' =>
'1+'
1096 'functionCall' =>
'PHPExcel_Calculation_Statistical::MINIF',
1097 'argumentCount' =>
'2+'
1100 'functionCall' =>
'PHPExcel_Calculation_DateTime::MINUTEOFHOUR',
1101 'argumentCount' =>
'1'
1104 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MINVERSE',
1105 'argumentCount' =>
'1'
1108 'functionCall' =>
'PHPExcel_Calculation_Financial::MIRR',
1109 'argumentCount' =>
'3'
1112 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MMULT',
1113 'argumentCount' =>
'2'
1116 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MOD',
1117 'argumentCount' =>
'2'
1120 'functionCall' =>
'PHPExcel_Calculation_Statistical::MODE',
1121 'argumentCount' =>
'1+'
1124 'functionCall' =>
'PHPExcel_Calculation_DateTime::MONTHOFYEAR',
1125 'argumentCount' =>
'1'
1128 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MROUND',
1129 'argumentCount' =>
'2'
1132 'functionCall' =>
'PHPExcel_Calculation_MathTrig::MULTINOMIAL',
1133 'argumentCount' =>
'1+'
1136 'functionCall' =>
'PHPExcel_Calculation_Functions::N',
1137 'argumentCount' =>
'1'
1140 'functionCall' =>
'PHPExcel_Calculation_Functions::NA',
1141 'argumentCount' =>
'0'
1144 'functionCall' =>
'PHPExcel_Calculation_Statistical::NEGBINOMDIST',
1145 'argumentCount' =>
'3'
1148 'functionCall' =>
'PHPExcel_Calculation_DateTime::NETWORKDAYS',
1149 'argumentCount' =>
'2+'
1152 'functionCall' =>
'PHPExcel_Calculation_Financial::NOMINAL',
1153 'argumentCount' =>
'2'
1156 'functionCall' =>
'PHPExcel_Calculation_Statistical::NORMDIST',
1157 'argumentCount' =>
'4'
1160 'functionCall' =>
'PHPExcel_Calculation_Statistical::NORMINV',
1161 'argumentCount' =>
'3'
1164 'functionCall' =>
'PHPExcel_Calculation_Statistical::NORMSDIST',
1165 'argumentCount' =>
'1'
1168 'functionCall' =>
'PHPExcel_Calculation_Statistical::NORMSINV',
1169 'argumentCount' =>
'1'
1172 'functionCall' =>
'PHPExcel_Calculation_Logical::NOT',
1173 'argumentCount' =>
'1'
1176 'functionCall' =>
'PHPExcel_Calculation_DateTime::DATETIMENOW',
1177 'argumentCount' =>
'0'
1180 'functionCall' =>
'PHPExcel_Calculation_Financial::NPER',
1181 'argumentCount' =>
'3-5'
1184 'functionCall' =>
'PHPExcel_Calculation_Financial::NPV',
1185 'argumentCount' =>
'2+'
1188 'functionCall' =>
'PHPExcel_Calculation_Engineering::OCTTOBIN',
1189 'argumentCount' =>
'1,2'
1192 'functionCall' =>
'PHPExcel_Calculation_Engineering::OCTTODEC',
1193 'argumentCount' =>
'1'
1196 'functionCall' =>
'PHPExcel_Calculation_Engineering::OCTTOHEX',
1197 'argumentCount' =>
'1,2'
1200 'functionCall' =>
'PHPExcel_Calculation_MathTrig::ODD',
1201 'argumentCount' =>
'1'
1204 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1205 'argumentCount' =>
'8,9'
1208 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1209 'argumentCount' =>
'8,9'
1212 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1213 'argumentCount' =>
'7,8'
1216 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1217 'argumentCount' =>
'7,8'
1220 'functionCall' =>
'PHPExcel_Calculation_LookupRef::OFFSET',
1221 'argumentCount' =>
'3,5',
1222 'passCellReference'=>
true,
1223 'passByReference' => array(
true)
1226 'functionCall' =>
'PHPExcel_Calculation_Logical::LOGICAL_OR',
1227 'argumentCount' =>
'1+'
1230 'functionCall' =>
'PHPExcel_Calculation_Statistical::CORREL',
1231 'argumentCount' =>
'2'
1234 'functionCall' =>
'PHPExcel_Calculation_Statistical::PERCENTILE',
1235 'argumentCount' =>
'2'
1238 'functionCall' =>
'PHPExcel_Calculation_Statistical::PERCENTRANK',
1239 'argumentCount' =>
'2,3'
1242 'functionCall' =>
'PHPExcel_Calculation_Statistical::PERMUT',
1243 'argumentCount' =>
'2'
1246 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1247 'argumentCount' =>
'1'
1250 'functionCall' =>
'pi',
1251 'argumentCount' =>
'0'
1254 'functionCall' =>
'PHPExcel_Calculation_Financial::PMT',
1255 'argumentCount' =>
'3-5'
1258 'functionCall' =>
'PHPExcel_Calculation_Statistical::POISSON',
1259 'argumentCount' =>
'3'
1262 'functionCall' =>
'PHPExcel_Calculation_MathTrig::POWER',
1263 'argumentCount' =>
'2'
1266 'functionCall' =>
'PHPExcel_Calculation_Financial::PPMT',
1267 'argumentCount' =>
'4-6'
1270 'functionCall' =>
'PHPExcel_Calculation_Financial::PRICE',
1271 'argumentCount' =>
'6,7'
1274 'functionCall' =>
'PHPExcel_Calculation_Financial::PRICEDISC',
1275 'argumentCount' =>
'4,5'
1278 'functionCall' =>
'PHPExcel_Calculation_Financial::PRICEMAT',
1279 'argumentCount' =>
'5,6'
1282 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1283 'argumentCount' =>
'3,4'
1286 'functionCall' =>
'PHPExcel_Calculation_MathTrig::PRODUCT',
1287 'argumentCount' =>
'1+'
1290 'functionCall' =>
'PHPExcel_Calculation_TextData::PROPERCASE',
1291 'argumentCount' =>
'1'
1294 'functionCall' =>
'PHPExcel_Calculation_Financial::PV',
1295 'argumentCount' =>
'3-5'
1298 'functionCall' =>
'PHPExcel_Calculation_Statistical::QUARTILE',
1299 'argumentCount' =>
'2'
1302 'functionCall' =>
'PHPExcel_Calculation_MathTrig::QUOTIENT',
1303 'argumentCount' =>
'2'
1306 'functionCall' =>
'deg2rad',
1307 'argumentCount' =>
'1'
1310 'functionCall' =>
'PHPExcel_Calculation_MathTrig::RAND',
1311 'argumentCount' =>
'0'
1314 'functionCall' =>
'PHPExcel_Calculation_MathTrig::RAND',
1315 'argumentCount' =>
'2'
1318 'functionCall' =>
'PHPExcel_Calculation_Statistical::RANK',
1319 'argumentCount' =>
'2,3'
1322 'functionCall' =>
'PHPExcel_Calculation_Financial::RATE',
1323 'argumentCount' =>
'3-6'
1326 'functionCall' =>
'PHPExcel_Calculation_Financial::RECEIVED',
1327 'argumentCount' =>
'4-5'
1330 'functionCall' =>
'PHPExcel_Calculation_TextData::REPLACE',
1331 'argumentCount' =>
'4'
1334 'functionCall' =>
'PHPExcel_Calculation_TextData::REPLACE',
1335 'argumentCount' =>
'4'
1338 'functionCall' =>
'str_repeat',
1339 'argumentCount' =>
'2'
1342 'functionCall' =>
'PHPExcel_Calculation_TextData::RIGHT',
1343 'argumentCount' =>
'1,2'
1346 'functionCall' =>
'PHPExcel_Calculation_TextData::RIGHT',
1347 'argumentCount' =>
'1,2'
1350 'functionCall' =>
'PHPExcel_Calculation_MathTrig::ROMAN',
1351 'argumentCount' =>
'1,2'
1354 'functionCall' =>
'round',
1355 'argumentCount' =>
'2'
1358 'functionCall' =>
'PHPExcel_Calculation_MathTrig::ROUNDDOWN',
1359 'argumentCount' =>
'2'
1362 'functionCall' =>
'PHPExcel_Calculation_MathTrig::ROUNDUP',
1363 'argumentCount' =>
'2'
1366 'functionCall' =>
'PHPExcel_Calculation_LookupRef::ROW',
1367 'argumentCount' =>
'-1',
1368 'passByReference' => array(
true)
1371 'functionCall' =>
'PHPExcel_Calculation_LookupRef::ROWS',
1372 'argumentCount' =>
'1'
1375 'functionCall' =>
'PHPExcel_Calculation_Statistical::RSQ',
1376 'argumentCount' =>
'2'
1379 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1380 'argumentCount' =>
'1+'
1383 'functionCall' =>
'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE',
1384 'argumentCount' =>
'2,3'
1387 'functionCall' =>
'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE',
1388 'argumentCount' =>
'2,3'
1391 'functionCall' =>
'PHPExcel_Calculation_DateTime::SECONDOFMINUTE',
1392 'argumentCount' =>
'1'
1395 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SERIESSUM',
1396 'argumentCount' =>
'4'
1399 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SIGN',
1400 'argumentCount' =>
'1'
1403 'functionCall' =>
'sin',
1404 'argumentCount' =>
'1'
1407 'functionCall' =>
'sinh',
1408 'argumentCount' =>
'1'
1411 'functionCall' =>
'PHPExcel_Calculation_Statistical::SKEW',
1412 'argumentCount' =>
'1+'
1415 'functionCall' =>
'PHPExcel_Calculation_Financial::SLN',
1416 'argumentCount' =>
'3'
1419 'functionCall' =>
'PHPExcel_Calculation_Statistical::SLOPE',
1420 'argumentCount' =>
'2'
1423 'functionCall' =>
'PHPExcel_Calculation_Statistical::SMALL',
1424 'argumentCount' =>
'2'
1427 'functionCall' =>
'sqrt',
1428 'argumentCount' =>
'1'
1431 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SQRTPI',
1432 'argumentCount' =>
'1'
1435 'functionCall' =>
'PHPExcel_Calculation_Statistical::STANDARDIZE',
1436 'argumentCount' =>
'3'
1439 'functionCall' =>
'PHPExcel_Calculation_Statistical::STDEV',
1440 'argumentCount' =>
'1+'
1443 'functionCall' =>
'PHPExcel_Calculation_Statistical::STDEVA',
1444 'argumentCount' =>
'1+'
1447 'functionCall' =>
'PHPExcel_Calculation_Statistical::STDEVP',
1448 'argumentCount' =>
'1+'
1451 'functionCall' =>
'PHPExcel_Calculation_Statistical::STDEVPA',
1452 'argumentCount' =>
'1+'
1455 'functionCall' =>
'PHPExcel_Calculation_Statistical::STEYX',
1456 'argumentCount' =>
'2'
1459 'functionCall' =>
'PHPExcel_Calculation_TextData::SUBSTITUTE',
1460 'argumentCount' =>
'3,4'
1463 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUBTOTAL',
1464 'argumentCount' =>
'2+'
1467 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUM',
1468 'argumentCount' =>
'1+'
1471 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMIF',
1472 'argumentCount' =>
'2,3'
1475 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1476 'argumentCount' =>
'?'
1479 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMPRODUCT',
1480 'argumentCount' =>
'1+'
1483 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMSQ',
1484 'argumentCount' =>
'1+'
1487 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMX2MY2',
1488 'argumentCount' =>
'2'
1491 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMX2PY2',
1492 'argumentCount' =>
'2'
1495 'functionCall' =>
'PHPExcel_Calculation_MathTrig::SUMXMY2',
1496 'argumentCount' =>
'2'
1499 'functionCall' =>
'PHPExcel_Calculation_Financial::SYD',
1500 'argumentCount' =>
'4'
1503 'functionCall' =>
'PHPExcel_Calculation_TextData::RETURNSTRING',
1504 'argumentCount' =>
'1'
1507 'functionCall' =>
'tan',
1508 'argumentCount' =>
'1'
1511 'functionCall' =>
'tanh',
1512 'argumentCount' =>
'1'
1515 'functionCall' =>
'PHPExcel_Calculation_Financial::TBILLEQ',
1516 'argumentCount' =>
'3'
1519 'functionCall' =>
'PHPExcel_Calculation_Financial::TBILLPRICE',
1520 'argumentCount' =>
'3'
1523 'functionCall' =>
'PHPExcel_Calculation_Financial::TBILLYIELD',
1524 'argumentCount' =>
'3'
1527 'functionCall' =>
'PHPExcel_Calculation_Statistical::TDIST',
1528 'argumentCount' =>
'3'
1531 'functionCall' =>
'PHPExcel_Calculation_TextData::TEXTFORMAT',
1532 'argumentCount' =>
'2'
1535 'functionCall' =>
'PHPExcel_Calculation_DateTime::TIME',
1536 'argumentCount' =>
'3'
1539 'functionCall' =>
'PHPExcel_Calculation_DateTime::TIMEVALUE',
1540 'argumentCount' =>
'1'
1543 'functionCall' =>
'PHPExcel_Calculation_Statistical::TINV',
1544 'argumentCount' =>
'2'
1547 'functionCall' =>
'PHPExcel_Calculation_DateTime::DATENOW',
1548 'argumentCount' =>
'0'
1551 'functionCall' =>
'PHPExcel_Calculation_LookupRef::TRANSPOSE',
1552 'argumentCount' =>
'1'
1555 'functionCall' =>
'PHPExcel_Calculation_Statistical::TREND',
1556 'argumentCount' =>
'1-4'
1559 'functionCall' =>
'PHPExcel_Calculation_TextData::TRIMSPACES',
1560 'argumentCount' =>
'1'
1563 'functionCall' =>
'PHPExcel_Calculation_Statistical::TRIMMEAN',
1564 'argumentCount' =>
'2'
1567 'functionCall' =>
'PHPExcel_Calculation_Logical::TRUE',
1568 'argumentCount' =>
'0'
1571 'functionCall' =>
'PHPExcel_Calculation_MathTrig::TRUNC',
1572 'argumentCount' =>
'1,2'
1575 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1576 'argumentCount' =>
'4'
1579 'functionCall' =>
'PHPExcel_Calculation_Functions::TYPE',
1580 'argumentCount' =>
'1'
1583 'functionCall' =>
'PHPExcel_Calculation_TextData::UPPERCASE',
1584 'argumentCount' =>
'1'
1587 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1588 'argumentCount' =>
'2'
1591 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1592 'argumentCount' =>
'1'
1595 'functionCall' =>
'PHPExcel_Calculation_Statistical::VARFunc',
1596 'argumentCount' =>
'1+'
1599 'functionCall' =>
'PHPExcel_Calculation_Statistical::VARA',
1600 'argumentCount' =>
'1+'
1603 'functionCall' =>
'PHPExcel_Calculation_Statistical::VARP',
1604 'argumentCount' =>
'1+'
1607 'functionCall' =>
'PHPExcel_Calculation_Statistical::VARPA',
1608 'argumentCount' =>
'1+'
1611 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1612 'argumentCount' =>
'5-7'
1615 'functionCall' =>
'PHPExcel_Calculation_Functions::VERSION',
1616 'argumentCount' =>
'0'
1619 'functionCall' =>
'PHPExcel_Calculation_LookupRef::VLOOKUP',
1620 'argumentCount' =>
'3,4'
1623 'functionCall' =>
'PHPExcel_Calculation_DateTime::DAYOFWEEK',
1624 'argumentCount' =>
'1,2'
1627 'functionCall' =>
'PHPExcel_Calculation_DateTime::WEEKOFYEAR',
1628 'argumentCount' =>
'1,2'
1631 'functionCall' =>
'PHPExcel_Calculation_Statistical::WEIBULL',
1632 'argumentCount' =>
'4'
1635 'functionCall' =>
'PHPExcel_Calculation_DateTime::WORKDAY',
1636 'argumentCount' =>
'2+'
1639 'functionCall' =>
'PHPExcel_Calculation_Financial::XIRR',
1640 'argumentCount' =>
'2,3'
1643 'functionCall' =>
'PHPExcel_Calculation_Financial::XNPV',
1644 'argumentCount' =>
'3'
1647 'functionCall' =>
'PHPExcel_Calculation_DateTime::YEAR',
1648 'argumentCount' =>
'1'
1651 'functionCall' =>
'PHPExcel_Calculation_DateTime::YEARFRAC',
1652 'argumentCount' =>
'2,3'
1655 'functionCall' =>
'PHPExcel_Calculation_Functions::DUMMY',
1656 'argumentCount' =>
'6,7'
1659 'functionCall' =>
'PHPExcel_Calculation_Financial::YIELDDISC',
1660 'argumentCount' =>
'4,5'
1663 'functionCall' =>
'PHPExcel_Calculation_Financial::YIELDMAT',
1664 'argumentCount' =>
'5,6'
1667 'functionCall' =>
'PHPExcel_Calculation_Statistical::ZTEST',
1668 'argumentCount' =>
'2-3'
1675 'MKMATRIX' => array(
'argumentCount' =>
'*',
1676 'functionCall' =>
'self::_mkMatrix'
1684 $localeFileDirectory = PHPEXCEL_ROOT.
'PHPExcel/locale/';
1685 foreach (glob($localeFileDirectory.
'/*',GLOB_ONLYDIR) as
$filename) {
1686 $filename = substr($filename,strlen($localeFileDirectory)+1);
1687 if ($filename !=
'en') {
1688 self::$_validLocaleLanguages[] =
$filename;
1692 $setPrecision = (PHP_INT_SIZE == 4) ? 12 : 16;
1693 $this->_savedPrecision = ini_get(
'precision');
1694 if ($this->_savedPrecision < $setPrecision) {
1695 ini_set(
'precision',$setPrecision);
1701 ini_set(
'precision',$this->_savedPrecision);
1711 if (!isset(self::$_instance) || is_null(self::$_instance)) {
1727 if (isset(self::$_instance) && !is_null(self::$_instance)) {
1728 self::$_instance->clearCalculationCache();
1740 throw new Exception (
'Cloning a Singleton is not allowed!');
1751 return self::$_localeBoolean[
'TRUE'];
1761 return self::$_localeBoolean[
'FALSE'];
1772 if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
1773 ($returnType == self::RETURN_ARRAY_AS_ERROR) ||
1774 ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
1775 self::$returnArrayAsType = $returnType;
1811 self::$_calculationCacheEnabled = $pValue;
1836 self::$_calculationCache = array();
1856 self::$_calculationCacheExpirationTime = $pValue;
1879 $language = $locale = strtolower($locale);
1880 if (strpos($locale,
'_') !==
false) {
1881 list($language) = explode(
'_',$locale);
1885 if (in_array($language,self::$_validLocaleLanguages)) {
1887 self::$_localeFunctions = array();
1888 self::$_localeArgumentSeparator =
',';
1889 self::$_localeBoolean = array(
'TRUE' =>
'TRUE',
'FALSE' =>
'FALSE',
'NULL' =>
'NULL');
1891 if ($locale !=
'en_us') {
1893 $functionNamesFile = PHPEXCEL_ROOT .
'PHPExcel/locale/'.str_replace(
'_',
'/',$locale).
'/functions';
1894 if (!file_exists($functionNamesFile)) {
1896 $functionNamesFile = PHPEXCEL_ROOT .
'PHPExcel/locale/'.$language.
'/functions';
1897 if (!file_exists($functionNamesFile)) {
1902 $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
1903 foreach ($localeFunctions as $localeFunction) {
1904 list($localeFunction) = explode(
'##',$localeFunction);
1905 if (strpos($localeFunction,
'=') !==
false) {
1906 list($fName,$lfName) = explode(
'=',$localeFunction);
1907 $fName = trim($fName);
1908 $lfName = trim($lfName);
1909 if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName !=
'') && ($fName != $lfName)) {
1910 self::$_localeFunctions[$fName] = $lfName;
1915 if (isset(self::$_localeFunctions[
'TRUE'])) { self::$_localeBoolean[
'TRUE'] = self::$_localeFunctions[
'TRUE']; }
1916 if (isset(self::$_localeFunctions[
'FALSE'])) { self::$_localeBoolean[
'FALSE'] = self::$_localeFunctions[
'FALSE']; }
1918 $configFile = PHPEXCEL_ROOT .
'PHPExcel/locale/'.str_replace(
'_',
'/',$locale).
'/config';
1919 if (!file_exists($configFile)) {
1920 $configFile = PHPEXCEL_ROOT .
'PHPExcel/locale/'.$language.
'/config';
1922 if (file_exists($configFile)) {
1923 $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
1924 foreach ($localeSettings as $localeSetting) {
1925 list($localeSetting) = explode(
'##',$localeSetting);
1926 if (strpos($localeSetting,
'=') !==
false) {
1927 list($settingName,$settingValue) = explode(
'=',$localeSetting);
1928 $settingName = strtoupper(trim($settingName));
1929 switch ($settingName) {
1930 case 'ARGUMENTSEPARATOR' :
1931 self::$_localeArgumentSeparator = trim($settingValue);
1939 self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
1940 self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null;
1941 self::$_localeLanguage = $locale;
1950 $strlen = mb_strlen($formula);
1951 for ($i = 0; $i < $strlen; ++$i) {
1952 $chr = mb_substr($formula,$i,1);
1954 case '{' : $inBraces =
true;
1956 case '}' : $inBraces =
false;
1958 case $fromSeparator :
1960 $formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1);
1969 if (self::$_localeLanguage !==
'en_us') {
1972 if (strpos($formula,
'"') !==
false) {
1975 $temp = explode(
'"',$formula);
1977 foreach($temp as &$value) {
1980 $value = preg_replace($from,$to,$value);
1986 $formula = implode(
'"',$temp);
1989 $formula = preg_replace($from,$to,$formula);
2001 if (is_null(self::$functionReplaceFromExcel)) {
2002 self::$functionReplaceFromExcel = array();
2003 foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
2004 self::$functionReplaceFromExcel[] =
'/(@?[^\w\.])'.preg_quote($excelFunctionName).
'([\s]*\()/Ui';
2006 foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
2007 self::$functionReplaceFromExcel[] =
'/(@?[^\w\.])'.preg_quote($excelBoolean).
'([^\w\.])/Ui';
2012 if (is_null(self::$functionReplaceToLocale)) {
2013 self::$functionReplaceToLocale = array();
2014 foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
2015 self::$functionReplaceToLocale[] =
'$1'.trim($localeFunctionName).
'$2';
2017 foreach(array_values(self::$_localeBoolean) as $localeBoolean) {
2018 self::$functionReplaceToLocale[] =
'$1'.trim($localeBoolean).
'$2';
2022 return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,
',',self::$_localeArgumentSeparator);
2030 if (is_null(self::$functionReplaceFromLocale)) {
2031 self::$functionReplaceFromLocale = array();
2032 foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
2033 self::$functionReplaceFromLocale[] =
'/(@?[^\w\.])'.preg_quote($localeFunctionName).
'([\s]*\()/Ui';
2035 foreach(array_values(self::$_localeBoolean) as $excelBoolean) {
2036 self::$functionReplaceFromLocale[] =
'/(@?[^\w\.])'.preg_quote($excelBoolean).
'([^\w\.])/Ui';
2040 if (is_null(self::$functionReplaceToExcel)) {
2041 self::$functionReplaceToExcel = array();
2042 foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
2043 self::$functionReplaceToExcel[] =
'$1'.trim($excelFunctionName).
'$2';
2045 foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
2046 self::$functionReplaceToExcel[] =
'$1'.trim($excelBoolean).
'$2';
2050 return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,
',');
2055 if (self::$_localeLanguage !==
'en_us') {
2056 $functionName = trim($function,
'(');
2057 if (isset(self::$_localeFunctions[$functionName])) {
2058 $brace = ($functionName != $function);
2059 $function = self::$_localeFunctions[$functionName];
2060 if ($brace) { $function .=
'('; }
2076 if (is_string($value)) {
2078 if (preg_match(
'/^'.self::CALCULATION_REGEXP_ERROR.
'$/i', $value, $match)) {
2083 return '"'.$value.
'"';
2085 }
else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
2100 if (is_string($value)) {
2101 if ((isset($value{0})) && ($value{0} ==
'"') && (substr($value,-1) ==
'"')) {
2102 return substr($value,1,-1);
2105 }
else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
2144 $this->formulaError = null;
2145 $this->debugLog = $this->debugLogStack = array();
2146 $this->_cyclicFormulaCount = 1;
2153 if (is_null($pCell)) {
2167 if ((is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
2169 if (self::$returnArrayAsType == self::RETURN_ARRAY_AS_ERROR) {
2173 if (count($testResult) != 1) {
2175 $r = array_keys($result);
2176 $r = array_shift($r);
2178 if (is_array($result[$r])) {
2179 $c = array_keys($result[$r]);
2180 $c = array_shift($c);
2181 if (!is_numeric($c)) {
2186 $result = array_shift($testResult);
2189 if (is_null($result)) {
2191 } elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
2208 $formula = trim($formula);
2209 if ((!isset($formula{0})) || ($formula{0} !=
'='))
return array();
2210 $formula = ltrim(substr($formula,1));
2211 if (!isset($formula{0}))
return array();
2227 $this->formulaError = null;
2228 $this->debugLog = $this->debugLogStack = array();
2233 self::$_calculationCacheEnabled =
false;
2242 self::$_calculationCacheEnabled = $resetCache;
2263 $formula = trim($formula);
2264 if ($formula{0} !=
'=')
return self::_wrapResult($formula);
2265 $formula = ltrim(substr($formula,1));
2268 $wsTitle =
"\x00Wrk";
2269 if (!is_null($pCell)) {
2270 $pCellParent = $pCell->getParent();
2271 if (!is_null($pCellParent)) {
2272 $wsTitle = $pCellParent->getTitle();
2276 if (!is_null($cellID)) {
2277 if (self::$_calculationCacheEnabled) {
2280 if (isset(self::$_calculationCache[$wsTitle][$cellID])) {
2282 $this->
_writeDebug(
'Testing cache value for cell '.$cellID);
2284 if ((microtime(
true) - self::$_calculationCache[$wsTitle][$cellID][
'time']) < self::$_calculationCacheExpirationTime) {
2286 $this->
_writeDebug(
'Retrieving value for '.$cellID.
' from cache');
2288 $returnValue = self::$_calculationCache[$wsTitle][$cellID][
'data'];
2290 if (is_array($returnValue)) {
2292 return array_shift($returnValue);
2294 return $returnValue;
2297 $this->
_writeDebug(
'Cache value for '.$cellID.
' has expired');
2299 unset(self::$_calculationCache[$wsTitle][$cellID]);
2305 if ((in_array($wsTitle.
'!'.$cellID,$this->debugLogStack)) && ($wsTitle !=
"\x00Wrk")) {
2306 if ($this->cyclicFormulaCount <= 0) {
2308 } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
2309 ($this->_cyclicFormulaCell == $wsTitle.
'!'.$cellID)) {
2311 } elseif ($this->_cyclicFormulaCell == $wsTitle.
'!'.$cellID) {
2313 if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
2316 } elseif ($this->_cyclicFormulaCell ==
'') {
2317 $this->_cyclicFormulaCell = $wsTitle.
'!'.$cellID;
2318 if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
2323 $this->debugLogStack[] = $wsTitle.
'!'.$cellID;
2326 array_pop($this->debugLogStack);
2329 if (!is_null($cellID)) {
2330 if (self::$_calculationCacheEnabled) {
2331 self::$_calculationCache[$wsTitle][$cellID][
'time'] = microtime(
true);
2332 self::$_calculationCache[$wsTitle][$cellID][
'data'] = $cellValue;
2356 if (!is_array($operand1)) {
2358 $operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1));
2360 } elseif (!is_array($operand2)) {
2362 $operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2));
2368 if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
2375 } elseif ($resize == 1) {
2379 return array( $matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
2390 $matrixRows = count($matrix);
2392 foreach($matrix as $rowKey => $rowValue) {
2393 $matrixColumns = max(count($rowValue),$matrixColumns);
2394 if (!is_array($rowValue)) {
2395 $matrix[$rowKey] = array($rowValue);
2397 $matrix[$rowKey] = array_values($rowValue);
2400 $matrix = array_values($matrix);
2401 return array($matrixRows,$matrixColumns);
2411 private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
2412 if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
2413 if ($matrix2Columns < $matrix1Columns) {
2414 for ($i = 0; $i < $matrix1Rows; ++$i) {
2415 for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
2416 unset($matrix1[$i][$j]);
2420 if ($matrix2Rows < $matrix1Rows) {
2421 for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) {
2422 unset($matrix1[$i]);
2427 if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
2428 if ($matrix1Columns < $matrix2Columns) {
2429 for ($i = 0; $i < $matrix2Rows; ++$i) {
2430 for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
2431 unset($matrix2[$i][$j]);
2435 if ($matrix1Rows < $matrix2Rows) {
2436 for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) {
2437 unset($matrix2[$i]);
2450 private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
2451 if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
2452 if ($matrix2Columns < $matrix1Columns) {
2453 for ($i = 0; $i < $matrix2Rows; ++$i) {
2454 $x = $matrix2[$i][$matrix2Columns-1];
2455 for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
2456 $matrix2[$i][$j] =
$x;
2460 if ($matrix2Rows < $matrix1Rows) {
2461 $x = $matrix2[$matrix2Rows-1];
2462 for ($i = 0; $i < $matrix1Rows; ++$i) {
2468 if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
2469 if ($matrix1Columns < $matrix2Columns) {
2470 for ($i = 0; $i < $matrix1Rows; ++$i) {
2471 $x = $matrix1[$i][$matrix1Columns-1];
2472 for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
2473 $matrix1[$i][$j] =
$x;
2477 if ($matrix1Rows < $matrix2Rows) {
2478 $x = $matrix1[$matrix1Rows-1];
2479 for ($i = 0; $i < $matrix2Rows; ++$i) {
2494 if ($this->writeDebugLog) {
2496 if (count($testArray) == 1) {
2497 $value = array_pop($testArray);
2500 if (is_array($value)) {
2501 $returnMatrix = array();
2502 $pad = $rpad =
', ';
2503 foreach($value as
$row) {
2504 if (is_array($row)) {
2505 $returnMatrix[] = implode($pad,$row);
2508 $returnMatrix[] =
$row;
2511 return '{ '.implode($rpad,$returnMatrix).
' }';
2512 } elseif(is_bool($value)) {
2513 return ($value) ? self::$_localeBoolean[
'TRUE'] : self::$_localeBoolean[
'FALSE'];
2527 if ($this->writeDebugLog) {
2529 if (count($testArray) == 1) {
2530 $value = array_pop($testArray);
2533 if (is_null($value)) {
2534 return 'a null value';
2535 } elseif (is_float($value)) {
2536 $typeString =
'a floating point number';
2537 } elseif(is_int($value)) {
2538 $typeString =
'an integer number';
2539 } elseif(is_bool($value)) {
2540 $typeString =
'a boolean';
2541 } elseif(is_array($value)) {
2542 $typeString =
'a matrix';
2545 return 'an empty string';
2546 } elseif ($value{0} ==
'#') {
2547 return 'a '.$value.
' error';
2549 $typeString =
'a string';
2552 return $typeString.
' with a value of '.$this->
_showValue($value);
2558 static $matrixReplaceFrom = array(
'{',
';',
'}');
2559 static $matrixReplaceTo = array(
'MKMATRIX(MKMATRIX(',
'),MKMATRIX(',
'))');
2562 if (strpos($formula,
'{') !==
false) {
2564 if (strpos($formula,
'"') !==
false) {
2567 $temp = explode(
'"',$formula);
2569 $openCount = $closeCount = 0;
2571 foreach($temp as &$value) {
2574 $openCount += substr_count($value,
'{');
2575 $closeCount += substr_count($value,
'}');
2576 $value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value);
2581 $formula = implode(
'"',$temp);
2584 $openCount = substr_count($formula,
'{');
2585 $closeCount = substr_count($formula,
'}');
2586 $formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula);
2589 if ($openCount < $closeCount) {
2590 if ($openCount > 0) {
2595 } elseif ($openCount > $closeCount) {
2596 if ($closeCount > 0) {
2609 return func_get_args();
2615 if (($formula = self::_convertMatrixReferences(trim($formula))) ===
false) {
2621 $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
2626 $operatorAssociativity = array(
'^' => 0,
2631 '>' => 0,
'<' => 0,
'=' => 0,
'>=' => 0,
'<=' => 0,
'<>' => 0
2635 $comparisonOperators = array(
'>' =>
true,
'<' =>
true,
'=' =>
true,
'>=' =>
true,
'<=' =>
true,
'<>' =>
true);
2640 $operatorPrecedence = array(
':' => 8,
2648 '>' => 0,
'<' => 0,
'=' => 0,
'>=' => 0,
'<=' => 0,
'<>' => 0
2651 $regexpMatchString =
'/^('.self::CALCULATION_REGEXP_FUNCTION.
2652 '|'.self::CALCULATION_REGEXP_NUMBER.
2653 '|'.self::CALCULATION_REGEXP_STRING.
2654 '|'.self::CALCULATION_REGEXP_OPENBRACE.
2655 '|'.self::CALCULATION_REGEXP_CELLREF.
2656 '|'.self::CALCULATION_REGEXP_NAMEDRANGE.
2657 '|'.self::CALCULATION_REGEXP_ERROR.
2664 $expectingOperator =
false;
2666 $expectingOperand =
false;
2672 $opCharacter = $formula{$index};
2674 if ((isset($comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset($comparisonOperators[$formula{$index+1}]))) {
2675 $opCharacter .= $formula{++$index};
2680 $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match);
2684 if ($opCharacter ==
'-' && !$expectingOperator) {
2686 $stack->push(
'Unary Operator',
'~');
2688 } elseif ($opCharacter ==
'%' && $expectingOperator) {
2690 $stack->push(
'Unary Operator',
'%');
2692 } elseif ($opCharacter ==
'+' && !$expectingOperator) {
2695 } elseif ((($opCharacter ==
'~') || ($opCharacter ==
'|')) && (!$isOperandOrFunction)) {
2698 } elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) {
2700 while($stack->count() > 0 &&
2701 ($o2 = $stack->last()) &&
2702 isset(self::$_operators[$o2[
'value']]) &&
2703 @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2[
'value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2[
'value']])) {
2704 $output[] = $stack->pop();
2706 $stack->push(
'Binary Operator',$opCharacter);
2708 $expectingOperator =
false;
2710 } elseif ($opCharacter ==
')' && $expectingOperator) {
2712 $expectingOperand =
false;
2713 while (($o2 = $stack->pop()) && $o2[
'value'] !=
'(') {
2714 if (is_null($o2))
return $this->
_raiseFormulaError(
'Formula Error: Unexpected closing brace ")"');
2715 else $output[] = $o2;
2717 $d = $stack->last(2);
2718 if (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i',
$d[
'value'], $matches)) {
2719 $functionName = $matches[1];
2722 $argumentCount =
$d[
'value'];
2731 $output[] = $stack->pop();
2732 if (isset(self::$_controlFunctions[$functionName])) {
2734 $expectedArgumentCount = self::$_controlFunctions[$functionName][
'argumentCount'];
2735 $functionCall = self::$_controlFunctions[$functionName][
'functionCall'];
2736 } elseif (isset(self::$_PHPExcelFunctions[$functionName])) {
2738 $expectedArgumentCount = self::$_PHPExcelFunctions[$functionName][
'argumentCount'];
2739 $functionCall = self::$_PHPExcelFunctions[$functionName][
'functionCall'];
2741 return $this->
_raiseFormulaError(
"Formula Error: Internal error, non-function on stack");
2744 $argumentCountError =
false;
2745 if (is_numeric($expectedArgumentCount)) {
2746 if ($expectedArgumentCount < 0) {
2748 if ($argumentCount > abs($expectedArgumentCount)) {
2749 $argumentCountError =
true;
2750 $expectedArgumentCountString =
'no more than '.abs($expectedArgumentCount);
2754 if ($argumentCount != $expectedArgumentCount) {
2755 $argumentCountError =
true;
2756 $expectedArgumentCountString = $expectedArgumentCount;
2759 } elseif ($expectedArgumentCount !=
'*') {
2760 $isOperandOrFunction = preg_match(
'/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch);
2763 switch ($argMatch[2]) {
2765 if ($argumentCount < $argMatch[1]) {
2766 $argumentCountError =
true;
2767 $expectedArgumentCountString = $argMatch[1].
' or more ';
2771 if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
2772 $argumentCountError =
true;
2773 $expectedArgumentCountString =
'between '.$argMatch[1].
' and '.$argMatch[3];
2777 if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
2778 $argumentCountError =
true;
2779 $expectedArgumentCountString =
'either '.$argMatch[1].
' or '.$argMatch[3];
2784 if ($argumentCountError) {
2785 return $this->
_raiseFormulaError(
"Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString.
" expected");
2790 } elseif ($opCharacter ==
',') {
2792 while (($o2 = $stack->pop()) && $o2[
'value'] !=
'(') {
2794 else $output[] = $o2;
2798 if (($expectingOperand) || (!$expectingOperator)) {
2799 $output[] = array(
'type' =>
'NULL Value',
'value' => self::$_ExcelConstants[
'NULL'],
'reference' => null);
2802 $d = $stack->last(2);
2803 if (!preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i',
$d[
'value'], $matches))
2806 $stack->push(
$d[
'type'],++
$d[
'value'],
$d[
'reference']);
2807 $stack->push(
'Brace',
'(');
2808 $expectingOperator =
false;
2809 $expectingOperand =
true;
2812 } elseif ($opCharacter ==
'(' && !$expectingOperator) {
2814 $stack->push(
'Brace',
'(');
2817 } elseif ($isOperandOrFunction && !$expectingOperator) {
2818 $expectingOperator =
true;
2819 $expectingOperand =
false;
2821 $length = strlen($val);
2824 if (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $val, $matches)) {
2825 $val = preg_replace(
'/\s/',
'',$val);
2827 if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) {
2828 $stack->push(
'Function', strtoupper($val));
2829 $ax = preg_match(
'/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
2831 $stack->push(
'Operand Count for Function '.self::_localeFunc(strtoupper($val)).
')', 0);
2832 $expectingOperator =
true;
2834 $stack->push(
'Operand Count for Function '.self::_localeFunc(strtoupper($val)).
')', 1);
2835 $expectingOperator =
false;
2837 $stack->push(
'Brace',
'(');
2839 $output[] = array(
'type' =>
'Value',
'value' => $matches[1],
'reference' => null);
2841 } elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'$/i', $val, $matches)) {
2847 $testPrevOp = $stack->last(1);
2848 if ($testPrevOp[
'value'] ==
':') {
2850 if ($matches[2] ==
'') {
2853 $startCellRef = $output[count($output)-1][
'value'];
2854 preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'$/i', $startCellRef, $startMatches);
2855 if ($startMatches[2] >
'') {
2856 $val = $startMatches[2].
'!'.$val;
2863 $output[] = array(
'type' =>
'Cell Reference',
'value' => $val,
'reference' => $val);
2868 $testPrevOp = $stack->last(1);
2869 if ($testPrevOp[
'value'] ==
':') {
2870 $startRowColRef = $output[count($output)-1][
'value'];
2872 if (strpos(
'!',$startRowColRef) !==
false) {
2873 list($rangeWS1,$startRowColRef) = explode(
'!',$startRowColRef);
2875 if ($rangeWS1 !=
'') $rangeWS1 .=
'!';
2876 $rangeWS2 = $rangeWS1;
2877 if (strpos(
'!',$val) !==
false) {
2878 list($rangeWS2,$val) = explode(
'!',$val);
2880 if ($rangeWS2 !=
'') $rangeWS2 .=
'!';
2881 if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
2882 ($startRowColRef <= 1048576) && ($val <= 1048576)) {
2884 $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestColumn() :
'XFD';
2885 $output[count($output)-1][
'value'] = $rangeWS1.
'A'.$startRowColRef;
2886 $val = $rangeWS2.$endRowColRef.$val;
2887 } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
2888 (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
2890 $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestRow() : 1048576;
2891 $output[count($output)-1][
'value'] = $rangeWS1.strtoupper($startRowColRef).
'1';
2892 $val = $rangeWS2.$val.$endRowColRef;
2896 $localeConstant =
false;
2897 if ($opCharacter ==
'"') {
2901 } elseif (is_numeric($val)) {
2903 if ((strpos($val,
'.') !==
false) || (stripos($val,
'e') !==
false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
2905 $val = (float) $val;
2908 $val = (integer) $val;
2910 } elseif (isset(self::$_ExcelConstants[trim(strtoupper($val))])) {
2911 $excelConstant = trim(strtoupper($val));
2913 $val = self::$_ExcelConstants[$excelConstant];
2914 } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !==
false) {
2916 $val = self::$_ExcelConstants[$localeConstant];
2918 $details = array(
'type' =>
'Value',
'value' => $val,
'reference' => null);
2919 if ($localeConstant) { $details[
'localeValue'] = $localeConstant; }
2920 $output[] = $details;
2924 } elseif ($opCharacter ==
'$') {
2926 } elseif ($opCharacter ==
')') {
2927 if ($expectingOperand) {
2928 $output[] = array(
'type' =>
'Null Value',
'value' => self::$_ExcelConstants[
'NULL'],
'reference' => null);
2929 $expectingOperand =
false;
2930 $expectingOperator =
true;
2934 } elseif (isset(self::$_operators[$opCharacter]) && !$expectingOperator) {
2935 return $this->
_raiseFormulaError(
"Formula Error: Unexpected operator '$opCharacter'");
2940 if ($index == strlen($formula)) {
2943 if ((isset(self::$_operators[$opCharacter])) && ($opCharacter !=
'%')) {
2944 return $this->
_raiseFormulaError(
"Formula Error: Operator '$opCharacter' has no operands");
2950 while (($formula{$index} ==
"\n") || ($formula{$index} ==
"\r")) {
2953 if ($formula{$index} ==
' ') {
2954 while ($formula{$index} ==
' ') {
2960 if (($expectingOperator) && (preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'.*/Ui', substr($formula, $index), $match)) &&
2961 ($output[count($output)-1][
'type'] ==
'Cell Reference')) {
2963 while($stack->count() > 0 &&
2964 ($o2 = $stack->last()) &&
2965 isset(self::$_operators[$o2[
'value']]) &&
2966 @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2[
'value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2[
'value']])) {
2967 $output[] = $stack->pop();
2969 $stack->push(
'Binary Operator',
'|');
2970 $expectingOperator =
false;
2975 while (!is_null($op = $stack->pop())) {
2976 if ($opCharacter[
'value'] ==
'(')
return $this->
_raiseFormulaError(
"Formula Error: Expecting ')'");
2985 if ($tokens ==
false)
return false;
2989 $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
2993 foreach ($tokens as $tokenData) {
2996 $token = $tokenData[
'value'];
2999 if (isset(self::$_binaryOperators[$token])) {
3002 if (is_null($operand2Data = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
3003 if (is_null($operand1Data = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
3005 $operand1 = $operand1Data[
'value'];
3006 $operand2 = $operand2Data[
'value'];
3007 if ($token ==
':') {
3008 $this->
_writeDebug(
'Evaluating Range '.$this->
_showValue($operand1Data[
'reference']).$token.$this->_showValue($operand2Data[
'reference']));
3010 $this->
_writeDebug(
'Evaluating '.$this->
_showValue($operand1).
' '.$token.
' '.$this->_showValue($operand2));
3025 $sheet1 = $sheet2 =
'';
3026 if (strpos($operand1Data[
'reference'],
'!') !==
false) {
3027 list($sheet1,$operand1Data[
'reference']) = explode(
'!',$operand1Data[
'reference']);
3029 $sheet1 = (!is_null($pCellParent)) ? $pCellParent->getTitle() :
'';
3031 if (strpos($operand2Data[
'reference'],
'!') !==
false) {
3032 list($sheet2,$operand2Data[
'reference']) = explode(
'!',$operand2Data[
'reference']);
3036 if ($sheet1 == $sheet2) {
3037 if (is_null($operand1Data[
'reference'])) {
3038 if ((trim($operand1Data[
'value']) !=
'') && (is_numeric($operand1Data[
'value']))) {
3039 $operand1Data[
'reference'] = $pCell->getColumn().$operand1Data[
'value'];
3040 } elseif (trim($operand1Data[
'reference']) ==
'') {
3041 $operand1Data[
'reference'] = $pCell->getCoordinate();
3043 $operand1Data[
'reference'] = $operand1Data[
'value'].$pCell->getRow();
3046 if (is_null($operand2Data[
'reference'])) {
3047 if ((trim($operand2Data[
'value']) !=
'') && (is_numeric($operand2Data[
'value']))) {
3048 $operand2Data[
'reference'] = $pCell->getColumn().$operand2Data[
'value'];
3049 } elseif (trim($operand2Data[
'reference']) ==
'') {
3050 $operand2Data[
'reference'] = $pCell->getCoordinate();
3052 $operand2Data[
'reference'] = $operand2Data[
'value'].$pCell->getRow();
3056 $oData = array_merge(explode(
':',$operand1Data[
'reference']),explode(
':',$operand2Data[
'reference']));
3057 $oCol =
$oRow = array();
3058 foreach($oData as $oDatum) {
3064 if (!is_null($pCellParent)) {
3065 $cellValue = $this->
extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($sheet1),
false);
3069 $stack->push(
'Cell Reference',$cellValue,$cellRef);
3094 if (is_bool($operand1)) {
3095 $operand1 = ($operand1) ? self::$_localeBoolean[
'TRUE'] : self::$_localeBoolean[
'FALSE'];
3097 if (is_bool($operand2)) {
3098 $operand2 = ($operand2) ? self::$_localeBoolean[
'TRUE'] : self::$_localeBoolean[
'FALSE'];
3100 if ((is_array($operand1)) || (is_array($operand2))) {
3107 $matrixResult = $matrix->concat($operand2);
3108 $result = $matrixResult->getArray();
3110 $this->
_writeDebug(
'JAMA Matrix Exception: '.$ex->getMessage());
3111 $result =
'#VALUE!';
3114 $result =
'"'.str_replace(
'""',
'"',self::_unwrapResult($operand1,
'"').self::_unwrapResult($operand2,
'"')).
'"';
3117 $stack->push(
'Value',$result);
3120 $rowIntersect = array_intersect_key($operand1,$operand2);
3121 $cellIntersect = $oCol =
$oRow = array();
3122 foreach(array_keys($rowIntersect) as
$row) {
3124 foreach($rowIntersect[$row] as $col =>
$data) {
3126 $cellIntersect[
$row] = array_intersect_key($operand1[$row],$operand2[$row]);
3131 $stack->push(
'Value',$cellIntersect,$cellRef);
3136 } elseif (($token ===
'~') || ($token ===
'%')) {
3138 if (is_null(
$arg = $stack->pop()))
return $this->
_raiseFormulaError(
'Internal error - Operand value missing from stack');
3140 if ($token ===
'~') {
3149 if (is_array(
$arg)) {
3153 $matrixResult = $matrix1->arrayTimesEquals($multiplier);
3154 $result = $matrixResult->getArray();
3156 $this->
_writeDebug(
'JAMA Matrix Exception: '.$ex->getMessage());
3157 $result =
'#VALUE!';
3160 $stack->push(
'Value',$result);
3165 } elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_CELLREF.
'$/i', $token, $matches)) {
3168 if (isset($matches[8])) {
3170 if (is_null($pCell)) {
3174 $cellRef = $matches[6].$matches[7].
':'.$matches[9].$matches[10];
3175 if ($matches[2] >
'') {
3176 $matches[2] = trim($matches[2],
"\"'");
3178 $this->
_writeDebug(
'Evaluating Cell Range '.$cellRef.
' in worksheet '.$matches[2]);
3179 if (!is_null($pCellParent)) {
3180 $cellValue = $this->
extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]),
false);
3184 $this->
_writeDebug(
'Evaluation Result for cells '.$cellRef.
' in worksheet '.$matches[2].
' is '.$this->_showTypeDetails($cellValue));
3188 $this->
_writeDebug(
'Evaluating Cell Range '.$cellRef.
' in current worksheet');
3189 if (!is_null($pCellParent)) {
3194 $this->
_writeDebug(
'Evaluation Result for cells '.$cellRef.
' is '.$this->_showTypeDetails($cellValue));
3199 if (is_null($pCell)) {
3203 $cellRef = $matches[6].$matches[7];
3204 if ($matches[2] >
'') {
3205 $matches[2] = trim($matches[2],
"\"'");
3207 $this->
_writeDebug(
'Evaluating Cell '.$cellRef.
' in worksheet '.$matches[2]);
3208 if (!is_null($pCellParent)) {
3209 if ($pCellParent->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) {
3210 $cellValue = $this->
extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]),
false);
3211 $pCell->attach($pCellParent);
3218 $this->
_writeDebug(
'Evaluation Result for cell '.$cellRef.
' in worksheet '.$matches[2].
' is '.$this->_showTypeDetails($cellValue));
3222 $this->
_writeDebug(
'Evaluating Cell '.$cellRef.
' in current worksheet');
3223 if ($pCellParent->cellExists($cellRef)) {
3225 $pCell->attach($pCellParent);
3229 $this->
_writeDebug(
'Evaluation Result for cell '.$cellRef.
' is '.$this->_showTypeDetails($cellValue));
3233 $stack->push(
'Value',$cellValue,$cellRef);
3236 } elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_FUNCTION.
'$/i', $token, $matches)) {
3238 $functionName = $matches[1];
3239 $argCount = $stack->pop();
3240 $argCount = $argCount[
'value'];
3241 if ($functionName !=
'MKMATRIX') {
3242 $this->
_writeDebug(
'Evaluating Function '.self::_localeFunc($functionName).
'() with '.(($argCount == 0) ?
'no' : $argCount).
' argument'.(($argCount == 1) ?
'' :
's'));
3244 if ((isset(self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) {
3245 if (isset(self::$_PHPExcelFunctions[$functionName])) {
3246 $functionCall = self::$_PHPExcelFunctions[$functionName][
'functionCall'];
3247 $passByReference = isset(self::$_PHPExcelFunctions[$functionName][
'passByReference']);
3248 $passCellReference = isset(self::$_PHPExcelFunctions[$functionName][
'passCellReference']);
3249 } elseif (isset(self::$_controlFunctions[$functionName])) {
3250 $functionCall = self::$_controlFunctions[$functionName][
'functionCall'];
3251 $passByReference = isset(self::$_controlFunctions[$functionName][
'passByReference']);
3252 $passCellReference = isset(self::$_controlFunctions[$functionName][
'passCellReference']);
3256 $args = $argArrayVals = array();
3257 for ($i = 0; $i < $argCount; ++$i) {
3258 $arg = $stack->pop();
3259 $a = $argCount - $i - 1;
3260 if (($passByReference) &&
3261 (isset(self::$_PHPExcelFunctions[$functionName][
'passByReference'][$a])) &&
3262 (self::$_PHPExcelFunctions[$functionName][
'passByReference'][$a])) {
3263 if (is_null(
$arg[
'reference'])) {
3265 if ($functionName !=
'MKMATRIX') { $argArrayVals[] = $this->
_showValue($cellID); }
3267 $args[] =
$arg[
'reference'];
3268 if ($functionName !=
'MKMATRIX') { $argArrayVals[] = $this->
_showValue(
$arg[
'reference']); }
3272 if ($functionName !=
'MKMATRIX') { $argArrayVals[] = $this->
_showValue(
$arg[
'value']); }
3277 if (($passByReference) && ($argCount == 0)) {
3279 $argArrayVals[] = $this->
_showValue($cellID);
3284 if ($functionName !=
'MKMATRIX') {
3285 if ($this->writeDebugLog) {
3286 krsort($argArrayVals);
3314 if ($passCellReference) {
3317 if (strpos($functionCall,
'::') !==
false) {
3318 $result = call_user_func_array(explode(
'::',$functionCall),$args);
3320 foreach($args as &
$arg) {
3324 $result = call_user_func_array($functionCall,$args);
3327 if ($functionName !=
'MKMATRIX') {
3328 $this->
_writeDebug(
'Evaluation Result for '.self::_localeFunc($functionName).
'() function call is '.$this->
_showTypeDetails($result));
3330 $stack->push(
'Value',self::_wrapResult($result));
3335 if (isset(self::$_ExcelConstants[strtoupper($token)])) {
3336 $excelConstant = strtoupper($token);
3338 $stack->push(
'Constant Value',self::$_ExcelConstants[$excelConstant]);
3339 $this->
_writeDebug(
'Evaluating Constant '.$excelConstant.
' as '.$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
3340 } elseif ((is_numeric($token)) || (is_null($token)) || (is_bool($token)) || ($token ==
'') || ($token{0} ==
'"') || ($token{0} ==
'#')) {
3342 $stack->push(
'Value',$token);
3344 } elseif (preg_match(
'/^'.self::CALCULATION_REGEXP_NAMEDRANGE.
'$/i', $token, $matches)) {
3346 $namedRange = $matches[6];
3348 $this->
_writeDebug(
'Evaluating Named Range '.$namedRange);
3349 $cellValue = $this->
extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null),
false);
3350 $pCell->attach($pCellParent);
3351 $this->
_writeDebug(
'Evaluation Result for named range '.$namedRange.
' is '.$this->_showTypeDetails($cellValue));
3352 $stack->push(
'Named Range',$cellValue,$namedRange);
3360 $output = $stack->pop();
3361 $output = $output[
'value'];
3372 if (is_string($operand)) {
3377 if (!is_numeric($operand)) {
3379 if ($operand >
'' && $operand{0} ==
'#') {
3380 $stack->push(
'Value', $operand);
3385 $stack->push(
'Value',
'#VALUE!');
3399 if ((is_array($operand1)) || (is_array($operand2))) {
3401 if ((is_array($operand1)) && (!is_array($operand2))) {
3402 foreach($operand1 as
$x => $operandData) {
3403 $this->
_writeDebug(
'Evaluating '.$this->
_showValue($operandData).
' '.$operation.
' '.$this->_showValue($operand2));
3406 $result[
$x] = $r[
'value'];
3408 } elseif ((!is_array($operand1)) && (is_array($operand2))) {
3409 foreach($operand2 as
$x => $operandData) {
3410 $this->
_writeDebug(
'Evaluating '.$this->
_showValue($operand1).
' '.$operation.
' '.$this->_showValue($operandData));
3413 $result[
$x] = $r[
'value'];
3417 foreach($operand1 as
$x => $operandData) {
3418 $this->
_writeDebug(
'Evaluating '.$this->
_showValue($operandData).
' '.$operation.
' '.$this->_showValue($operand2[
$x]));
3421 $result[
$x] = $r[
'value'];
3427 $stack->push(
'Array',$result);
3432 if (is_string($operand1) && $operand1 >
'' && $operand1{0} ==
'"') { $operand1 =
self::_unwrapResult($operand1); }
3433 if (is_string($operand2) && $operand2 >
'' && $operand2{0} ==
'"') { $operand2 =
self::_unwrapResult($operand2); }
3436 switch ($operation) {
3439 $result = ($operand1 > $operand2);
3443 $result = ($operand1 < $operand2);
3447 $result = ($operand1 == $operand2);
3451 $result = ($operand1 >= $operand2);
3455 $result = ($operand1 <= $operand2);
3459 $result = ($operand1 != $operand2);
3466 $stack->push(
'Value',$result);
3476 $executeMatrixOperation =
false;
3480 if ((is_array($operand1)) || (is_array($operand2))) {
3482 $executeMatrixOperation =
true;
3487 if (array_sum($mSize) == 4) {
3488 $executeMatrixOperation =
false;
3489 $operand1 = $operand1[0][0];
3490 $operand2 = $operand2[0][0];
3494 if ($executeMatrixOperation) {
3499 $matrixResult = $matrix->$matrixFunction($operand2);
3500 $result = $matrixResult->getArray();
3502 $this->
_writeDebug(
'JAMA Matrix Exception: '.$ex->getMessage());
3503 $result =
'#VALUE!';
3507 ((is_string($operand1) && !is_numeric($operand1)) || (is_string($operand2) && !is_numeric($operand2)))) {
3511 switch ($operation) {
3514 $result = $operand1+$operand2;
3518 $result = $operand1-$operand2;
3522 $result = $operand1*$operand2;
3526 if ($operand2 == 0) {
3528 $stack->push(
'Value',
'#DIV/0!');
3532 $result = $operand1/$operand2;
3537 $result = pow($operand1,$operand2);
3546 $stack->push(
'Value',$result);
3553 if ($this->writeDebugLog) {
3554 if ($this->echoDebugLog) {
3555 echo implode(
' -> ',$this->debugLogStack).
' -> '.$message,
'<br />';
3557 $this->debugLog[] = implode(
' -> ',$this->debugLogStack).
' -> '.$message;
3564 $this->formulaError = $errorMessage;
3565 if (!$this->suppressFormulaErrors)
throw new Exception($errorMessage);
3566 trigger_error($errorMessage, E_USER_ERROR);
3580 $returnValue = array ();
3583 if (!is_null($pSheet)) {
3586 if (strpos ($pRange,
'!') !==
false) {
3589 $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
3591 $pRange = $worksheetReference[1];
3597 $pRange = $pSheet->getTitle().
'!'.$pRange;
3598 if (!isset($aReferences[1])) {
3600 list($currentCol,$currentRow) = sscanf($aReferences[0],
'%[A-Z]%d');
3601 if ($pSheet->cellExists($aReferences[0])) {
3602 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
3604 $returnValue[$currentRow][$currentCol] = null;
3608 foreach ($aReferences as $reference) {
3610 list($currentCol,$currentRow) = sscanf($reference,
'%[A-Z]%d');
3612 if ($pSheet->cellExists($reference)) {
3613 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
3615 $returnValue[$currentRow][$currentCol] = null;
3622 return $returnValue;
3636 $returnValue = array ();
3639 if (!is_null($pSheet)) {
3642 if (strpos ($pRange,
'!') !==
false) {
3645 $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
3647 $pRange = $worksheetReference[1];
3653 if (!is_null($namedRange)) {
3654 $pSheet = $namedRange->getWorksheet();
3656 $pRange = $namedRange->getRange();
3659 if (ctype_alpha($splitRange[0][0])) {
3660 $pRange = $splitRange[0][0] .
'1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
3661 } elseif(ctype_digit($splitRange[0][0])) {
3662 $pRange =
'A' . $splitRange[0][0] .
':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
3680 if (!isset($aReferences[1])) {
3683 if ($pSheet->cellExists($aReferences[0])) {
3684 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
3686 $returnValue[$currentRow][$currentCol] = null;
3690 foreach ($aReferences as $reference) {
3694 if ($pSheet->cellExists($reference)) {
3695 $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
3697 $returnValue[$currentRow][$currentCol] = null;
3706 return $returnValue;
3717 $pFunction = strtoupper ($pFunction);
3718 if (isset(self::$_PHPExcelFunctions[$pFunction])) {
3719 return (self::$_PHPExcelFunctions[$pFunction][
'functionCall'] !=
'PHPExcel_Calculation_Functions::DUMMY');
3733 $returnValue = array();
3735 foreach(self::$_PHPExcelFunctions as $functionName => $function) {
3736 if ($function[
'functionCall'] !=
'PHPExcel_Calculation_Functions::DUMMY') {
3739 $function[
'functionCall']
3745 return $returnValue;
3755 return array_keys(self::$_PHPExcelFunctions);
3765 $returnValue = array();
3767 foreach(self::$_PHPExcelFunctions as $functionName => $function) {
3768 if ($function[
'functionCall'] !=
'PHPExcel_Calculation_Functions::DUMMY') {
3769 $returnValue[] = $functionName;
3774 return $returnValue;
3795 $this->_stack[$this->_count++] = array(
'type' =>
$type,
3797 'reference' => $reference
3799 if (
$type ==
'Function') {
3801 if ($localeFunction != $value) {
3802 $this->_stack[($this->_count - 1)][
'localeValue'] = $localeFunction;
3809 if ($this->_count > 0) {
3817 if ($this->_count-$n < 0) {
3820 return $this->_stack[$this->_count-$n];