/var/www/hkosl.com/imusiccircle/webadmin/libraies/phpoffice/phpexcel/Classes/PHPExcel/Calculation.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
<?php
/**
 * PHPExcel
 *
 * Copyright (c) 2006 - 2014 PHPExcel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel_Calculation
 * @copyright  Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
 * @version    ##VERSION##, ##DATE##
 */


/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
    
/**
     * @ignore
     */
    
define('PHPEXCEL_ROOT'dirname(__FILE__) . '/../');
    require(
PHPEXCEL_ROOT 'PHPExcel/Autoloader.php');
}


if (!
defined('CALCULATION_REGEXP_CELLREF')) {
    
//    Test for support of \P (multibyte options) in PCRE
    
if(defined('PREG_BAD_UTF8_ERROR')) {
        
//    Cell reference (cell or range of cells, with or without a sheet reference)
        
define('CALCULATION_REGEXP_CELLREF','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d{1,7})');
        
//    Named Range of cells
        
define('CALCULATION_REGEXP_NAMEDRANGE','((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)');
    } else {
        
//    Cell reference (cell or range of cells, with or without a sheet reference)
        
define('CALCULATION_REGEXP_CELLREF','(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)');
        
//    Named Range of cells
        
define('CALCULATION_REGEXP_NAMEDRANGE','(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9\.]*)');
    }
}


/**
 * PHPExcel_Calculation (Multiton)
 *
 * @category    PHPExcel
 * @package        PHPExcel_Calculation
 * @copyright    Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
 */
class PHPExcel_Calculation {

    
/** Constants                */
    /** Regular Expressions        */
    //    Numeric operand
    
const CALCULATION_REGEXP_NUMBER        '[-+]?\d*\.?\d+(e[-+]?\d+)?';
    
//    String operand
    
const CALCULATION_REGEXP_STRING        '"(?:[^"]|"")*"';
    
//    Opening bracket
    
const CALCULATION_REGEXP_OPENBRACE    '\(';
    
//    Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it)
    
const CALCULATION_REGEXP_FUNCTION    '@?([A-Z][A-Z0-9\.]*)[\s]*\(';
    
//    Cell reference (cell or range of cells, with or without a sheet reference)
    
const CALCULATION_REGEXP_CELLREF    CALCULATION_REGEXP_CELLREF;
    
//    Named Range of cells
    
const CALCULATION_REGEXP_NAMEDRANGE    CALCULATION_REGEXP_NAMEDRANGE;
    
//    Error
    
const CALCULATION_REGEXP_ERROR        '\#[A-Z][A-Z0_\/]*[!\?]?';


    
/** constants */
    
const RETURN_ARRAY_AS_ERROR 'error';
    const 
RETURN_ARRAY_AS_VALUE 'value';
    const 
RETURN_ARRAY_AS_ARRAY 'array';

    private static 
$returnArrayAsType    self::RETURN_ARRAY_AS_VALUE;


    
/**
     * Instance of this class
     *
     * @access    private
     * @var PHPExcel_Calculation
     */
    
private static $_instance;


    
/**
     * Instance of the workbook this Calculation Engine is using
     *
     * @access    private
     * @var PHPExcel
     */
    
private $_workbook;

    
/**
     * List of instances of the calculation engine that we've instantiated for individual workbooks
     *
     * @access    private
     * @var PHPExcel_Calculation[]
     */
    
private static $_workbookSets;

    
/**
     * Calculation cache
     *
     * @access    private
     * @var array
     */
    
private $_calculationCache = array ();


    
/**
     * Calculation cache enabled
     *
     * @access    private
     * @var boolean
     */
    
private $_calculationCacheEnabled TRUE;


    
/**
     * List of operators that can be used within formulae
     * The true/false value indicates whether it is a binary operator or a unary operator
     *
     * @access    private
     * @var array
     */
    
private static $_operators            = array('+' => TRUE,    '-' => TRUE,    '*' => TRUE,    '/' => TRUE,
                                                
'^' => TRUE,    '&' => TRUE,    '%' => FALSE,    '~' => FALSE,
                                                
'>' => TRUE,    '<' => TRUE,    '=' => TRUE,    '>=' => TRUE,
                                                
'<=' => TRUE,    '<>' => TRUE,    '|' => TRUE,    ':' => TRUE
                                               
);


    
/**
     * List of binary operators (those that expect two operands)
     *
     * @access    private
     * @var array
     */
    
private static $_binaryOperators    = array('+' => TRUE,    '-' => TRUE,    '*' => TRUE,    '/' => TRUE,
                                                
'^' => TRUE,    '&' => TRUE,    '>' => TRUE,    '<' => TRUE,
                                                
'=' => TRUE,    '>=' => TRUE,    '<=' => TRUE,    '<>' => TRUE,
                                                
'|' => TRUE,    ':' => TRUE
                                               
);

    
/**
     * The debug log generated by the calculation engine
     *
     * @access    private
     * @var PHPExcel_CalcEngine_Logger
     *
     */
    
private $debugLog;

    
/**
     * Flag to determine how formula errors should be handled
     *        If true, then a user error will be triggered
     *        If false, then an exception will be thrown
     *
     * @access    public
     * @var boolean
     *
     */
    
public $suppressFormulaErrors FALSE;

    
/**
     * Error message for any error that was raised/thrown by the calculation engine
     *
     * @access    public
     * @var string
     *
     */
    
public $formulaError NULL;

    
/**
     * An array of the nested cell references accessed by the calculation engine, used for the debug log
     *
     * @access    private
     * @var array of string
     *
     */
    
private $_cyclicReferenceStack;

    private 
$_cellStack = array();

    
/**
     * Current iteration counter for cyclic formulae
     * If the value is 0 (or less) then cyclic formulae will throw an exception,
     *    otherwise they will iterate to the limit defined here before returning a result
     *
     * @var integer
     *
     */
    
private $_cyclicFormulaCount 1;

    private 
$_cyclicFormulaCell '';

    
/**
     * Number of iterations for cyclic formulae
     *
     * @var integer
     *
     */
    
public $cyclicFormulaCount 1;

    
/**
     * Precision used for calculations
     *
     * @var integer
     *
     */
    
private $_savedPrecision    14;


    
/**
     * The current locale setting
     *
     * @var string
     *
     */
    
private static $_localeLanguage 'en_us';                    //    US English    (default locale)

    /**
     * List of available locale settings
     * Note that this is read for the locale subdirectory only when requested
     *
     * @var string[]
     *
     */
    
private static $_validLocaleLanguages = array(    'en'        //    English        (default language)
                                                 
);
    
/**
     * Locale-specific argument separator for function arguments
     *
     * @var string
     *
     */
    
private static $_localeArgumentSeparator ',';
    private static 
$_localeFunctions = array();

    
/**
     * Locale-specific translations for Excel constants (True, False and Null)
     *
     * @var string[]
     *
     */
    
public static $_localeBoolean = array(    'TRUE'    => 'TRUE',
                                            
'FALSE'    => 'FALSE',
                                            
'NULL'    => 'NULL'
                                          
);


    
/**
     * Excel constant string translations to their PHP equivalents
     * Constant conversion from text name/value to actual (datatyped) value
     *
     * @var string[]
     *
     */
    
private static $_ExcelConstants = array('TRUE'    => TRUE,
                                            
'FALSE'    => FALSE,
                                            
'NULL'    => NULL
                                           
);

    
//    PHPExcel functions
    
private static $_PHPExcelFunctions = array(    // PHPExcel functions
                
'ABS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'abs',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ACCRINT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::ACCRINT',
                                                 
'argumentCount'    =>    '4-7'
                                                
),
                
'ACCRINTM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::ACCRINTM',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'ACOS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'acos',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ACOSH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'acosh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ADDRESS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::CELL_ADDRESS',
                                                 
'argumentCount'    =>    '2-5'
                                                
),
                
'AMORDEGRC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::AMORDEGRC',
                                                 
'argumentCount'    =>    '6,7'
                                                
),
                
'AMORLINC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::AMORLINC',
                                                 
'argumentCount'    =>    '6,7'
                                                
),
                
'AND'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::LOGICAL_AND',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'AREAS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ASC'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ASIN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'asin',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ASINH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'asinh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ATAN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'atan',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ATAN2'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::ATAN2',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'ATANH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'atanh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'AVEDEV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::AVEDEV',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'AVERAGE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::AVERAGE',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'AVERAGEA'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::AVERAGEA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'AVERAGEIF'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::AVERAGEIF',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'AVERAGEIFS'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '3+'
                                                
),
                
'BAHTTEXT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'BESSELI'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BESSELI',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'BESSELJ'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BESSELJ',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'BESSELK'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BESSELK',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'BESSELY'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BESSELY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'BETADIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::BETADIST',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'BETAINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::BETAINV',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'BIN2DEC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BINTODEC',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'BIN2HEX'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BINTOHEX',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'BIN2OCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::BINTOOCT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'BINOMDIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::BINOMDIST',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'CEILING'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::CEILING',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'CELL'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'CHAR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::CHARACTER',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'CHIDIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CHIDIST',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'CHIINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CHIINV',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'CHITEST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'CHOOSE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::CHOOSE',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'CLEAN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::TRIMNONPRINTABLE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'CODE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::ASCIICODE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'COLUMN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::COLUMN',
                                                 
'argumentCount'    =>    '-1',
                                                 
'passByReference'    =>    array(TRUE)
                                                ),
                
'COLUMNS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::COLUMNS',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'COMBIN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::COMBIN',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'COMPLEX'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::COMPLEX',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'CONCATENATE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::CONCATENATE',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'CONFIDENCE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CONFIDENCE',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'CONVERT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::CONVERTUOM',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'CORREL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CORREL',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'COS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'cos',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'COSH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'cosh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'COUNT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::COUNT',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'COUNTA'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::COUNTA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'COUNTBLANK'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::COUNTBLANK',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'COUNTIF'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::COUNTIF',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'COUNTIFS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'COUPDAYBS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPDAYBS',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COUPDAYS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPDAYS',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COUPDAYSNC'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPDAYSNC',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COUPNCD'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPNCD',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COUPNUM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPNUM',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COUPPCD'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::COUPPCD',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'COVAR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::COVAR',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'CRITBINOM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CRITBINOM',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'CUBEKPIMEMBER'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBEMEMBER'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBEMEMBERPROPERTY'    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBERANKEDMEMBER'        => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBESET'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBESETCOUNT'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUBEVALUE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_CUBE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'CUMIPMT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::CUMIPMT',
                                                 
'argumentCount'    =>    '6'
                                                
),
                
'CUMPRINC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::CUMPRINC',
                                                 
'argumentCount'    =>    '6'
                                                
),
                
'DATE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DATE',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DATEDIF'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DATEDIF',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'DATEVALUE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DATEVALUE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'DAVERAGE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DAVERAGE',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DAY'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DAYOFMONTH',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'DAYS360'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DAYS360',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'DB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::DB',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'DCOUNT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DCOUNT',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DCOUNTA'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DCOUNTA',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DDB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::DDB',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'DEC2BIN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::DECTOBIN',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'DEC2HEX'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::DECTOHEX',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'DEC2OCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::DECTOOCT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'DEGREES'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'rad2deg',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'DELTA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::DELTA',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'DEVSQ'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::DEVSQ',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'DGET'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DGET',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DISC'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::DISC',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'DMAX'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DMAX',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DMIN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DMIN',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DOLLAR'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::DOLLAR',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'DOLLARDE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::DOLLARDE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'DOLLARFR'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::DOLLARFR',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'DPRODUCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DPRODUCT',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DSTDEV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DSTDEV',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DSTDEVP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DSTDEVP',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DSUM'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DSUM',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DURATION'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '5,6'
                                                
),
                
'DVAR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DVAR',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'DVARP'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATABASE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Database::DVARP',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'EDATE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::EDATE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'EFFECT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::EFFECT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'EOMONTH'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::EOMONTH',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'ERF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::ERF',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'ERFC'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::ERFC',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ERROR.TYPE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::ERROR_TYPE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'EVEN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::EVEN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'EXACT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'EXP'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'exp',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'EXPONDIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::EXPONDIST',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'FACT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::FACT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'FACTDOUBLE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::FACTDOUBLE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'FALSE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::FALSE',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'FDIST'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'FIND'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::SEARCHSENSITIVE',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'FINDB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::SEARCHSENSITIVE',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'FINV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'FISHER'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::FISHER',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'FISHERINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::FISHERINV',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'FIXED'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::FIXEDFORMAT',
                                                 
'argumentCount'    =>    '1-3'
                                                
),
                
'FLOOR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::FLOOR',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'FORECAST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::FORECAST',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'FREQUENCY'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'FTEST'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'FV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::FV',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'FVSCHEDULE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::FVSCHEDULE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'GAMMADIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::GAMMADIST',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'GAMMAINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::GAMMAINV',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'GAMMALN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::GAMMALN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'GCD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::GCD',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'GEOMEAN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::GEOMEAN',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'GESTEP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::GESTEP',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'GETPIVOTDATA'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'GROWTH'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::GROWTH',
                                                 
'argumentCount'    =>    '1-4'
                                                
),
                
'HARMEAN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::HARMEAN',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'HEX2BIN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::HEXTOBIN',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'HEX2DEC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::HEXTODEC',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'HEX2OCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::HEXTOOCT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'HLOOKUP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::HLOOKUP',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'HOUR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::HOUROFDAY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'HYPERLINK'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::HYPERLINK',
                                                 
'argumentCount'    =>    '1,2',
                                                 
'passCellReference'=>    TRUE
                                                
),
                
'HYPGEOMDIST'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::HYPGEOMDIST',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'IF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::STATEMENT_IF',
                                                 
'argumentCount'    =>    '1-3'
                                                
),
                
'IFERROR'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::IFERROR',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'IMABS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMABS',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMAGINARY'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMAGINARY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMARGUMENT'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMARGUMENT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMCONJUGATE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMCONJUGATE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMCOS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMCOS',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMDIV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMDIV',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'IMEXP'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMEXP',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMLN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMLN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMLOG10'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMLOG10',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMLOG2'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMLOG2',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMPOWER'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMPOWER',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'IMPRODUCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMPRODUCT',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'IMREAL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMREAL',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMSIN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMSIN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMSQRT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMSQRT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'IMSUB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMSUB',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'IMSUM'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::IMSUM',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'INDEX'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::INDEX',
                                                 
'argumentCount'    =>    '1-4'
                                                
),
                
'INDIRECT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::INDIRECT',
                                                 
'argumentCount'    =>    '1,2',
                                                 
'passCellReference'=>    TRUE
                                                
),
                
'INFO'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'INT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::INT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'INTERCEPT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::INTERCEPT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'INTRATE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::INTRATE',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'IPMT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::IPMT',
                                                 
'argumentCount'    =>    '4-6'
                                                
),
                
'IRR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::IRR',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'ISBLANK'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_BLANK',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISERR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_ERR',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISERROR'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_ERROR',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISEVEN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_EVEN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISLOGICAL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_LOGICAL',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISNA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_NA',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISNONTEXT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_NONTEXT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISNUMBER'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_NUMBER',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISODD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_ODD',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISPMT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::ISPMT',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'ISREF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ISTEXT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::IS_TEXT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'JIS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'KURT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::KURT',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'LARGE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::LARGE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'LCM'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::LCM',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'LEFT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::LEFT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'LEFTB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::LEFT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'LEN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::STRINGLENGTH',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'LENB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::STRINGLENGTH',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'LINEST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::LINEST',
                                                 
'argumentCount'    =>    '1-4'
                                                
),
                
'LN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'log',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'LOG'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::LOG_BASE',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'LOG10'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'log10',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'LOGEST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::LOGEST',
                                                 
'argumentCount'    =>    '1-4'
                                                
),
                
'LOGINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::LOGINV',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'LOGNORMDIST'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::LOGNORMDIST',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'LOOKUP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::LOOKUP',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'LOWER'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::LOWERCASE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'MATCH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::MATCH',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'MAX'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MAX',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MAXA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MAXA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MAXIF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MAXIF',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'MDETERM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MDETERM',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'MDURATION'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '5,6'
                                                
),
                
'MEDIAN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MEDIAN',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MEDIANIF'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'MID'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::MID',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'MIDB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::MID',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'MIN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MIN',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MINA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MINA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MINIF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MINIF',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'MINUTE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::MINUTEOFHOUR',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'MINVERSE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MINVERSE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'MIRR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::MIRR',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'MMULT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MMULT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'MOD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MOD',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'MODE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::MODE',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'MONTH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::MONTHOFYEAR',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'MROUND'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MROUND',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'MULTINOMIAL'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::MULTINOMIAL',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'N'                        => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::N',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'NA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::NA',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'NEGBINOMDIST'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::NEGBINOMDIST',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'NETWORKDAYS'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::NETWORKDAYS',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'NOMINAL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::NOMINAL',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'NORMDIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::NORMDIST',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'NORMINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::NORMINV',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'NORMSDIST'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::NORMSDIST',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'NORMSINV'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::NORMSINV',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'NOT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::NOT',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'NOW'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DATETIMENOW',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'NPER'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::NPER',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'NPV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::NPV',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'OCT2BIN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::OCTTOBIN',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'OCT2DEC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::OCTTODEC',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'OCT2HEX'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Engineering::OCTTOHEX',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'ODD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::ODD',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'ODDFPRICE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '8,9'
                                                
),
                
'ODDFYIELD'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '8,9'
                                                
),
                
'ODDLPRICE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '7,8'
                                                
),
                
'ODDLYIELD'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '7,8'
                                                
),
                
'OFFSET'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::OFFSET',
                                                 
'argumentCount'    =>    '3,5',
                                                 
'passCellReference'=>    TRUE,
                                                 
'passByReference'    =>    array(TRUE)
                                                ),
                
'OR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::LOGICAL_OR',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'PEARSON'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::CORREL',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'PERCENTILE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::PERCENTILE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'PERCENTRANK'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::PERCENTRANK',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'PERMUT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::PERMUT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'PHONETIC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'PI'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'pi',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'PMT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PMT',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'POISSON'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::POISSON',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'POWER'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::POWER',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'PPMT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PPMT',
                                                 
'argumentCount'    =>    '4-6'
                                                
),
                
'PRICE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PRICE',
                                                 
'argumentCount'    =>    '6,7'
                                                
),
                
'PRICEDISC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PRICEDISC',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'PRICEMAT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PRICEMAT',
                                                 
'argumentCount'    =>    '5,6'
                                                
),
                
'PROB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'PRODUCT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::PRODUCT',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'PROPER'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::PROPERCASE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'PV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::PV',
                                                 
'argumentCount'    =>    '3-5'
                                                
),
                
'QUARTILE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::QUARTILE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'QUOTIENT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::QUOTIENT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'RADIANS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'deg2rad',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'RAND'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::RAND',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'RANDBETWEEN'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::RAND',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'RANK'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::RANK',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'RATE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::RATE',
                                                 
'argumentCount'    =>    '3-6'
                                                
),
                
'RECEIVED'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::RECEIVED',
                                                 
'argumentCount'    =>    '4-5'
                                                
),
                
'REPLACE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::REPLACE',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'REPLACEB'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::REPLACE',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'REPT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'str_repeat',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'RIGHT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::RIGHT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'RIGHTB'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::RIGHT',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'ROMAN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::ROMAN',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'ROUND'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'round',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'ROUNDDOWN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::ROUNDDOWN',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'ROUNDUP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::ROUNDUP',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'ROW'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::ROW',
                                                 
'argumentCount'    =>    '-1',
                                                 
'passByReference'    =>    array(TRUE)
                                                ),
                
'ROWS'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::ROWS',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'RSQ'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::RSQ',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'RTD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'SEARCH'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'SEARCHB'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::SEARCHINSENSITIVE',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'SECOND'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::SECONDOFMINUTE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'SERIESSUM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SERIESSUM',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'SIGN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SIGN',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'SIN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'sin',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'SINH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'sinh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'SKEW'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::SKEW',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'SLN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::SLN',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'SLOPE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::SLOPE',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SMALL'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::SMALL',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SQRT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'sqrt',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'SQRTPI'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SQRTPI',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'STANDARDIZE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STANDARDIZE',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'STDEV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STDEV',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'STDEVA'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STDEVA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'STDEVP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STDEVP',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'STDEVPA'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STDEVPA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'STEYX'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::STEYX',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SUBSTITUTE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::SUBSTITUTE',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'SUBTOTAL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUBTOTAL',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'SUM'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUM',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'SUMIF'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMIF',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'SUMIFS'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '?'
                                                
),
                
'SUMPRODUCT'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMPRODUCT',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'SUMSQ'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMSQ',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'SUMX2MY2'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMX2MY2',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SUMX2PY2'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMX2PY2',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SUMXMY2'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::SUMXMY2',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'SYD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::SYD',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'T'                        => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::RETURNSTRING',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TAN'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'tan',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TANH'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'tanh',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TBILLEQ'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::TBILLEQ',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'TBILLPRICE'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::TBILLPRICE',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'TBILLYIELD'            => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::TBILLYIELD',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'TDIST'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::TDIST',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'TEXT'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::TEXTFORMAT',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'TIME'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::TIME',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'TIMEVALUE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::TIMEVALUE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TINV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::TINV',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'TODAY'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DATENOW',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'TRANSPOSE'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::TRANSPOSE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TREND'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::TREND',
                                                 
'argumentCount'    =>    '1-4'
                                                
),
                
'TRIM'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::TRIMSPACES',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'TRIMMEAN'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::TRIMMEAN',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'TRUE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Logical::TRUE',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'TRUNC'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_MathTrig::TRUNC',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'TTEST'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'TYPE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::TYPE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'UPPER'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::UPPERCASE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'USDOLLAR'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '2'
                                                
),
                
'VALUE'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_TextData::VALUE',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'VAR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::VARFunc',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'VARA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::VARA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'VARP'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::VARP',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'VARPA'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::VARPA',
                                                 
'argumentCount'    =>    '1+'
                                                
),
                
'VDB'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '5-7'
                                                
),
                
'VERSION'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::VERSION',
                                                 
'argumentCount'    =>    '0'
                                                
),
                
'VLOOKUP'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_LookupRef::VLOOKUP',
                                                 
'argumentCount'    =>    '3,4'
                                                
),
                
'WEEKDAY'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::DAYOFWEEK',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'WEEKNUM'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::WEEKOFYEAR',
                                                 
'argumentCount'    =>    '1,2'
                                                
),
                
'WEIBULL'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::WEIBULL',
                                                 
'argumentCount'    =>    '4'
                                                
),
                
'WORKDAY'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::WORKDAY',
                                                 
'argumentCount'    =>    '2+'
                                                
),
                
'XIRR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::XIRR',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'XNPV'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::XNPV',
                                                 
'argumentCount'    =>    '3'
                                                
),
                
'YEAR'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::YEAR',
                                                 
'argumentCount'    =>    '1'
                                                
),
                
'YEARFRAC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_DateTime::YEARFRAC',
                                                 
'argumentCount'    =>    '2,3'
                                                
),
                
'YIELD'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Functions::DUMMY',
                                                 
'argumentCount'    =>    '6,7'
                                                
),
                
'YIELDDISC'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::YIELDDISC',
                                                 
'argumentCount'    =>    '4,5'
                                                
),
                
'YIELDMAT'                => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Financial::YIELDMAT',
                                                 
'argumentCount'    =>    '5,6'
                                                
),
                
'ZTEST'                    => array('category'            =>    PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
                                                 
'functionCall'        =>    'PHPExcel_Calculation_Statistical::ZTEST',
                                                 
'argumentCount'    =>    '2-3'
                                                
)
            );


    
//    Internal functions used for special control purposes
    
private static $_controlFunctions = array(
                
'MKMATRIX'    => array('argumentCount'    =>    '*',
                                     
'functionCall'        =>    'self::_mkMatrix'
                                    
)
            );




    private function 
__construct(PHPExcel $workbook NULL) {
        
$setPrecision = (PHP_INT_SIZE == 4) ? 14 16;
        
$this->_savedPrecision ini_get('precision');
        if (
$this->_savedPrecision $setPrecision) {
            
ini_set('precision',$setPrecision);
        }
        
$this->delta pow(10, -$setPrecision);

        if (
$workbook !== NULL) {
            
self::$_workbookSets[$workbook->getID()] = $this;
        }

        
$this->_workbook $workbook;
        
$this->_cyclicReferenceStack = new PHPExcel_CalcEngine_CyclicReferenceStack();
        
$this->_debugLog = new PHPExcel_CalcEngine_Logger($this->_cyclicReferenceStack);
    }    
//    function __construct()


    
public function __destruct() {
        if (
$this->_savedPrecision != ini_get('precision')) {
            
ini_set('precision',$this->_savedPrecision);
        }
    }

    private static function 
_loadLocales() {
        
$localeFileDirectory PHPEXCEL_ROOT.'PHPExcel/locale/';
        foreach (
glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
            
$filename substr($filename,strlen($localeFileDirectory)+1);
            if (
$filename != 'en') {
                
self::$_validLocaleLanguages[] = $filename;
            }
        }
    }

    
/**
     * Get an instance of this class
     *
     * @access    public
     * @param   PHPExcel $workbook  Injected workbook for working with a PHPExcel object,
     *                                    or NULL to create a standalone claculation engine
     * @return PHPExcel_Calculation
     */
    
public static function getInstance(PHPExcel $workbook NULL) {
        if (
$workbook !== NULL) {
            if (isset(
self::$_workbookSets[$workbook->getID()])) {
                return 
self::$_workbookSets[$workbook->getID()];
            }
            return new 
PHPExcel_Calculation($workbook);
        }

        if (!isset(
self::$_instance) || (self::$_instance === NULL)) {
            
self::$_instance = new PHPExcel_Calculation();
        }

        return 
self::$_instance;
    }    
//    function getInstance()

    /**
     * Unset an instance of this class
     *
     * @access    public
     * @param   PHPExcel $workbook  Injected workbook identifying the instance to unset
     */
    
public static function unsetInstance(PHPExcel $workbook NULL) {
        if (
$workbook !== NULL) {
            if (isset(
self::$_workbookSets[$workbook->getID()])) {
                unset(
self::$_workbookSets[$workbook->getID()]);
            }
        }
    }

    
/**
     * Flush the calculation cache for any existing instance of this class
     *        but only if a PHPExcel_Calculation instance exists
     *
     * @access    public
     * @return null
     */
    
public function flushInstance() {
        
$this->clearCalculationCache();
    }    
//    function flushInstance()


    /**
     * Get the debuglog for this claculation engine instance
     *
     * @access    public
     * @return PHPExcel_CalcEngine_Logger
     */
    
public function getDebugLog() {
        return 
$this->_debugLog;
    }

    
/**
     * __clone implementation. Cloning should not be allowed in a Singleton!
     *
     * @access    public
     * @throws    PHPExcel_Calculation_Exception
     */
    
public final function __clone() {
        throw new 
PHPExcel_Calculation_Exception ('Cloning the calculation engine is not allowed!');
    }    
//    function __clone()


    /**
     * Return the locale-specific translation of TRUE
     *
     * @access    public
     * @return     string        locale-specific translation of TRUE
     */
    
public static function getTRUE() {
        return 
self::$_localeBoolean['TRUE'];
    }

    
/**
     * Return the locale-specific translation of FALSE
     *
     * @access    public
     * @return     string        locale-specific translation of FALSE
     */
    
public static function getFALSE() {
        return 
self::$_localeBoolean['FALSE'];
    }

    
/**
     * Set the Array Return Type (Array or Value of first element in the array)
     *
     * @access    public
     * @param     string    $returnType            Array return type
     * @return     boolean                    Success or failure
     */
    
public static function setArrayReturnType($returnType) {
        if ((
$returnType == self::RETURN_ARRAY_AS_VALUE) ||
            (
$returnType == self::RETURN_ARRAY_AS_ERROR) ||
            (
$returnType == self::RETURN_ARRAY_AS_ARRAY)) {
            
self::$returnArrayAsType $returnType;
            return 
TRUE;
        }
        return 
FALSE;
    }    
//    function setArrayReturnType()


    /**
     * Return the Array Return Type (Array or Value of first element in the array)
     *
     * @access    public
     * @return     string        $returnType            Array return type
     */
    
public static function getArrayReturnType() {
        return 
self::$returnArrayAsType;
    }    
//    function getArrayReturnType()


    /**
     * Is calculation caching enabled?
     *
     * @access    public
     * @return boolean
     */
    
public function getCalculationCacheEnabled() {
        return 
$this->_calculationCacheEnabled;
    }    
//    function getCalculationCacheEnabled()

    /**
     * Enable/disable calculation cache
     *
     * @access    public
     * @param boolean $pValue
     */
    
public function setCalculationCacheEnabled($pValue TRUE) {
        
$this->_calculationCacheEnabled $pValue;
        
$this->clearCalculationCache();
    }    
//    function setCalculationCacheEnabled()


    /**
     * Enable calculation cache
     */
    
public function enableCalculationCache() {
        
$this->setCalculationCacheEnabled(TRUE);
    }    
//    function enableCalculationCache()


    /**
     * Disable calculation cache
     */
    
public function disableCalculationCache() {
        
$this->setCalculationCacheEnabled(FALSE);
    }    
//    function disableCalculationCache()


    /**
     * Clear calculation cache
     */
    
public function clearCalculationCache() {
        
$this->_calculationCache = array();
    }    
//    function clearCalculationCache()

    /**
     * Clear calculation cache for a specified worksheet
     *
     * @param string $worksheetName
     */
    
public function clearCalculationCacheForWorksheet($worksheetName) {
        if (isset(
$this->_calculationCache[$worksheetName])) {
            unset(
$this->_calculationCache[$worksheetName]);
        }
    }    
//    function clearCalculationCacheForWorksheet()

    /**
     * Rename calculation cache for a specified worksheet
     *
     * @param string $fromWorksheetName
     * @param string $toWorksheetName
     */
    
public function renameCalculationCacheForWorksheet($fromWorksheetName$toWorksheetName) {
        if (isset(
$this->_calculationCache[$fromWorksheetName])) {
            
$this->_calculationCache[$toWorksheetName] = &$this->_calculationCache[$fromWorksheetName];
            unset(
$this->_calculationCache[$fromWorksheetName]);
        }
    }    
//    function renameCalculationCacheForWorksheet()


    /**
     * Get the currently defined locale code
     *
     * @return string
     */
    
public function getLocale() {
        return 
self::$_localeLanguage;
    }    
//    function getLocale()


    /**
     * Set the locale code
     *
     * @param string $locale  The locale to use for formula translation
     * @return boolean
     */
    
public function setLocale($locale 'en_us') {
        
//    Identify our locale and language
        
$language $locale strtolower($locale);
        if (
strpos($locale,'_') !== FALSE) {
            list(
$language) = explode('_',$locale);
        }

        if (
count(self::$_validLocaleLanguages) == 1)
            
self::_loadLocales();

        
//    Test whether we have any language data for this language (any locale)
        
if (in_array($language,self::$_validLocaleLanguages)) {
            
//    initialise language/locale settings
            
self::$_localeFunctions = array();
            
self::$_localeArgumentSeparator ',';
            
self::$_localeBoolean = array('TRUE' => 'TRUE''FALSE' => 'FALSE''NULL' => 'NULL');
            
//    Default is English, if user isn't requesting english, then read the necessary data from the locale files
            
if ($locale != 'en_us') {
                
//    Search for a file with a list of function names for locale
                
$functionNamesFile PHPEXCEL_ROOT 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'functions';
                if (!
file_exists($functionNamesFile)) {
                    
//    If there isn't a locale specific function file, look for a language specific function file
                    
$functionNamesFile PHPEXCEL_ROOT 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'functions';
                    if (!
file_exists($functionNamesFile)) {
                        return 
FALSE;
                    }
                }
                
//    Retrieve the list of locale or language specific function names
                
$localeFunctions file($functionNamesFile,FILE_IGNORE_NEW_LINES FILE_SKIP_EMPTY_LINES);
                foreach (
$localeFunctions as $localeFunction) {
                    list(
$localeFunction) = explode('##',$localeFunction);    //    Strip out comments
                    
if (strpos($localeFunction,'=') !== FALSE) {
                        list(
$fName,$lfName) = explode('=',$localeFunction);
                        
$fName trim($fName);
                        
$lfName trim($lfName);
                        if ((isset(
self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
                            
self::$_localeFunctions[$fName] = $lfName;
                        }
                    }
                }
                
//    Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
                
if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
                if (isset(
self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }

                
$configFile PHPEXCEL_ROOT 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.str_replace('_',DIRECTORY_SEPARATOR,$locale).DIRECTORY_SEPARATOR.'config';
                if (!
file_exists($configFile)) {
                    
$configFile PHPEXCEL_ROOT 'PHPExcel'.DIRECTORY_SEPARATOR.'locale'.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'config';
                }
                if (
file_exists($configFile)) {
                    
$localeSettings file($configFile,FILE_IGNORE_NEW_LINES FILE_SKIP_EMPTY_LINES);
                    foreach (
$localeSettings as $localeSetting) {
                        list(
$localeSetting) = explode('##',$localeSetting);    //    Strip out comments
                        
if (strpos($localeSetting,'=') !== FALSE) {
                            list(
$settingName,$settingValue) = explode('=',$localeSetting);
                            
$settingName strtoupper(trim($settingName));
                            switch (
$settingName) {
                                case 
'ARGUMENTSEPARATOR' :
                                    
self::$_localeArgumentSeparator trim($settingValue);
                                    break;
                            }
                        }
                    }
                }
            }

            
self::$functionReplaceFromExcel self::$functionReplaceToExcel =
            
self::$functionReplaceFromLocale self::$functionReplaceToLocale NULL;
            
self::$_localeLanguage $locale;
            return 
TRUE;
        }
        return 
FALSE;
    }    
//    function setLocale()



    
public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) {
        
$strlen mb_strlen($formula);
        for (
$i 0$i $strlen; ++$i) {
            
$chr mb_substr($formula,$i,1);
            switch (
$chr) {
                case 
'{' :    $inBraces TRUE;
                            break;
                case 
'}' :    $inBraces FALSE;
                            break;
                case 
$fromSeparator :
                            if (!
$inBraces) {
                                
$formula mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1);
                            }
            }
        }
        return 
$formula;
    }

    private static function 
_translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
        
//    Convert any Excel function names to the required language
        
if (self::$_localeLanguage !== 'en_us') {
            
$inBraces FALSE;
            
//    If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
            
if (strpos($formula,'"') !== FALSE) {
                
//    So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
                //        the formula
                
$temp explode('"',$formula);
                
$i FALSE;
                foreach(
$temp as &$value) {
                    
//    Only count/replace in alternating array entries
                    
if ($i = !$i) {
                        
$value preg_replace($from,$to,$value);
                        
$value self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces);
                    }
                }
                unset(
$value);
                
//    Then rebuild the formula string
                
$formula implode('"',$temp);
            } else {
                
//    If there's no quoted strings, then we do a simple count/replace
                
$formula preg_replace($from,$to,$formula);
                
$formula self::_translateSeparator($fromSeparator,$toSeparator,$formula,$inBraces);
            }
        }

        return 
$formula;
    }

    private static 
$functionReplaceFromExcel    NULL;
    private static 
$functionReplaceToLocale        NULL;

    public function 
_translateFormulaToLocale($formula) {
        if (
self::$functionReplaceFromExcel === NULL) {
            
self::$functionReplaceFromExcel = array();
            foreach(
array_keys(self::$_localeFunctions) as $excelFunctionName) {
                
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
            }
            foreach(
array_keys(self::$_localeBoolean) as $excelBoolean) {
                
self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
            }

        }

        if (
self::$functionReplaceToLocale === NULL) {
            
self::$functionReplaceToLocale = array();
            foreach(
array_values(self::$_localeFunctions) as $localeFunctionName) {
                
self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
            }
            foreach(
array_values(self::$_localeBoolean) as $localeBoolean) {
                
self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
            }
        }

        return 
self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator);
    }    
//    function _translateFormulaToLocale()


    
private static $functionReplaceFromLocale    NULL;
    private static 
$functionReplaceToExcel        NULL;

    public function 
_translateFormulaToEnglish($formula) {
        if (
self::$functionReplaceFromLocale === NULL) {
            
self::$functionReplaceFromLocale = array();
            foreach(
array_values(self::$_localeFunctions) as $localeFunctionName) {
                
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
            }
            foreach(
array_values(self::$_localeBoolean) as $excelBoolean) {
                
self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
            }
        }

        if (
self::$functionReplaceToExcel === NULL) {
            
self::$functionReplaceToExcel = array();
            foreach(
array_keys(self::$_localeFunctions) as $excelFunctionName) {
                
self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
            }
            foreach(
array_keys(self::$_localeBoolean) as $excelBoolean) {
                
self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
            }
        }

        return 
self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,',');
    }    
//    function _translateFormulaToEnglish()


    
public static function _localeFunc($function) {
        if (
self::$_localeLanguage !== 'en_us') {
            
$functionName trim($function,'(');
            if (isset(
self::$_localeFunctions[$functionName])) {
                
$brace = ($functionName != $function);
                
$function self::$_localeFunctions[$functionName];
                if (
$brace) { $function .= '('; }
            }
        }
        return 
$function;
    }




    
/**
     * Wrap string values in quotes
     *
     * @param mixed $value
     * @return mixed
     */
    
public static function _wrapResult($value) {
        if (
is_string($value)) {
            
//    Error values cannot be "wrapped"
            
if (preg_match('/^'.self::CALCULATION_REGEXP_ERROR.'$/i'$value$match)) {
                
//    Return Excel errors "as is"
                
return $value;
            }
            
//    Return strings wrapped in quotes
            
return '"'.$value.'"';
        
//    Convert numeric errors to NaN error
        
} else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
            return 
PHPExcel_Calculation_Functions::NaN();
        }

        return 
$value;
    }    
//    function _wrapResult()


    /**
     * Remove quotes used as a wrapper to identify string values
     *
     * @param mixed $value
     * @return mixed
     */
    
public static function _unwrapResult($value) {
        if (
is_string($value)) {
            if ((isset(
$value{0})) && ($value{0} == '"') && (substr($value,-1) == '"')) {
                return 
substr($value,1,-1);
            }
        
//    Convert numeric errors to NaN error
        
} else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
            return 
PHPExcel_Calculation_Functions::NaN();
        }
        return 
$value;
    }    
//    function _unwrapResult()




    /**
     * Calculate cell value (using formula from a cell ID)
     * Retained for backward compatibility
     *
     * @access    public
     * @param    PHPExcel_Cell    $pCell    Cell to calculate
     * @return    mixed
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function calculate(PHPExcel_Cell $pCell NULL) {
        try {
            return 
$this->calculateCellValue($pCell);
        } catch (
PHPExcel_Exception $e) {
            throw new 
PHPExcel_Calculation_Exception($e->getMessage());
        }
    }    
//    function calculate()


    /**
     * Calculate the value of a cell formula
     *
     * @access    public
     * @param    PHPExcel_Cell    $pCell        Cell to calculate
     * @param    Boolean            $resetLog    Flag indicating whether the debug log should be reset or not
     * @return    mixed
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function calculateCellValue(PHPExcel_Cell $pCell NULL$resetLog TRUE) {
        if (
$pCell === NULL) {
            return 
NULL;
        }

        
$returnArrayAsType self::$returnArrayAsType;
        if (
$resetLog) {
            
//    Initialise the logging settings if requested
            
$this->formulaError null;
            
$this->_debugLog->clearLog();
            
$this->_cyclicReferenceStack->clear();
            
$this->_cyclicFormulaCount 1;

            
self::$returnArrayAsType self::RETURN_ARRAY_AS_ARRAY;
        }

        
//    Execute the calculation for the cell formula
        
$this->_cellStack[] = array(
            
'sheet' => $pCell->getWorksheet()->getTitle(),
            
'cell' => $pCell->getCoordinate(),
        );
        try {
            
$result self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
            
$cellAddress array_pop($this->_cellStack);
            
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
        } catch (
PHPExcel_Exception $e) {
            
$cellAddress array_pop($this->_cellStack);
            
$this->_workbook->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
            throw new 
PHPExcel_Calculation_Exception($e->getMessage());
        }

        if ((
is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
            
self::$returnArrayAsType $returnArrayAsType;
            
$testResult PHPExcel_Calculation_Functions::flattenArray($result);
            if (
self::$returnArrayAsType == self::RETURN_ARRAY_AS_ERROR) {
                return 
PHPExcel_Calculation_Functions::VALUE();
            }
            
//    If there's only a single cell in the array, then we allow it
            
if (count($testResult) != 1) {
                
//    If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it
                
$r array_keys($result);
                
$r array_shift($r);
                if (!
is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); }
                if (
is_array($result[$r])) {
                    
$c array_keys($result[$r]);
                    
$c array_shift($c);
                    if (!
is_numeric($c)) {
                        return 
PHPExcel_Calculation_Functions::VALUE();
                    }
                }
            }
            
$result array_shift($testResult);
        }
        
self::$returnArrayAsType $returnArrayAsType;


        if (
$result === NULL) {
            return 
0;
        } elseif((
is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
            return 
PHPExcel_Calculation_Functions::NaN();
        }
        return 
$result;
    }    
//    function calculateCellValue(


    /**
     * Validate and parse a formula string
     *
     * @param    string        $formula        Formula to parse
     * @return    array
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function parseFormula($formula) {
        
//    Basic validation that this is indeed a formula
        //    We return an empty array if not
        
$formula trim($formula);
        if ((!isset(
$formula{0})) || ($formula{0} != '=')) return array();
        
$formula ltrim(substr($formula,1));
        if (!isset(
$formula{0})) return array();

        
//    Parse the formula and return the token stack
        
return $this->_parseFormula($formula);
    }    
//    function parseFormula()


    /**
     * Calculate the value of a formula
     *
     * @param    string            $formula    Formula to parse
     * @param    string            $cellID        Address of the cell to calculate
     * @param    PHPExcel_Cell    $pCell        Cell to calculate
     * @return    mixed
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function calculateFormula($formula$cellID=NULLPHPExcel_Cell $pCell NULL) {
        
//    Initialise the logging settings
        
$this->formulaError null;
        
$this->_debugLog->clearLog();
        
$this->_cyclicReferenceStack->clear();

        
//    Disable calculation cacheing because it only applies to cell calculations, not straight formulae
        //    But don't actually flush any cache
        
$resetCache $this->getCalculationCacheEnabled();
        
$this->_calculationCacheEnabled FALSE;
        
//    Execute the calculation
        
try {
            
$result self::_unwrapResult($this->_calculateFormulaValue($formula$cellID$pCell));
        } catch (
PHPExcel_Exception $e) {
            throw new 
PHPExcel_Calculation_Exception($e->getMessage());
        }

        
//    Reset calculation cacheing to its previous state
        
$this->_calculationCacheEnabled $resetCache;

        return 
$result;
    }    
//    function calculateFormula()


    
public function getValueFromCache($cellReference, &$cellValue) {
        
// Is calculation cacheing enabled?
        // Is the value present in calculation cache?
        
$this->_debugLog->writeDebugLog('Testing cache value for cell '$cellReference);
        if ((
$this->_calculationCacheEnabled) && (isset($this->_calculationCache[$cellReference]))) {
            
$this->_debugLog->writeDebugLog('Retrieving value for cell '$cellReference' from cache');
            
// Return the cached result
            
$cellValue $this->_calculationCache[$cellReference];
            return 
TRUE;
        }
        return 
FALSE;
    }

    public function 
saveValueToCache($cellReference$cellValue) {
        if (
$this->_calculationCacheEnabled) {
            
$this->_calculationCache[$cellReference] = $cellValue;
        }
    }

    
/**
     * Parse a cell formula and calculate its value
     *
     * @param    string            $formula    The formula to parse and calculate
     * @param    string            $cellID        The ID (e.g. A3) of the cell that we are calculating
     * @param    PHPExcel_Cell    $pCell        Cell to calculate
     * @return    mixed
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function _calculateFormulaValue($formula$cellID=nullPHPExcel_Cell $pCell null) {
        
$cellValue null;

        
//    Basic validation that this is indeed a formula
        //    We simply return the cell value if not
        
$formula trim($formula);
        if (
$formula{0} != '=') return self::_wrapResult($formula);
        
$formula ltrim(substr($formula1));
        if (!isset(
$formula{0})) return self::_wrapResult($formula);

        
$pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
        
$wsTitle = ($pCellParent !== NULL) ? $pCellParent->getTitle() : "\x00Wrk";
        
$wsCellReference $wsTitle '!' $cellID;

        if ((
$cellID !== NULL) && ($this->getValueFromCache($wsCellReference$cellValue))) {
            return 
$cellValue;
        }

        if ((
$wsTitle{0} !== "\x00") && ($this->_cyclicReferenceStack->onStack($wsCellReference))) {
            if (
$this->cyclicFormulaCount <= 0) {
                
$this->_cyclicFormulaCell '';
                return 
$this->_raiseFormulaError('Cyclic Reference in Formula');
            } elseif (
$this->_cyclicFormulaCell === $wsCellReference) {
                ++
$this->_cyclicFormulaCount;
                if (
$this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
                    
$this->_cyclicFormulaCell '';
                    return 
$cellValue;
                }
            } elseif (
$this->_cyclicFormulaCell == '') {
                if (
$this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
                    return 
$cellValue;
                }
                
$this->_cyclicFormulaCell $wsCellReference;
            }
        }

        
//    Parse the formula onto the token stack and calculate the value
        
$this->_cyclicReferenceStack->push($wsCellReference);
        
$cellValue $this->_processTokenStack($this->_parseFormula($formula$pCell), $cellID$pCell);
        
$this->_cyclicReferenceStack->pop();

        
// Save to calculation cache
        
if ($cellID !== NULL) {
            
$this->saveValueToCache($wsCellReference$cellValue);
        }

        
//    Return the calculated value
        
return $cellValue;
    }    
//    function _calculateFormulaValue()


    /**
     * Ensure that paired matrix operands are both matrices and of the same size
     *
     * @param    mixed        &$operand1    First matrix operand
     * @param    mixed        &$operand2    Second matrix operand
     * @param    integer        $resize        Flag indicating whether the matrices should be resized to match
     *                                        and (if so), whether the smaller dimension should grow or the
     *                                        larger should shrink.
     *                                            0 = no resize
     *                                            1 = shrink to fit
     *                                            2 = extend to fit
     */
    
private static function _checkMatrixOperands(&$operand1,&$operand2,$resize 1) {
        
//    Examine each of the two operands, and turn them into an array if they aren't one already
        //    Note that this function should only be called if one or both of the operand is already an array
        
if (!is_array($operand1)) {
            list(
$matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand2);
            
$operand1 array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1));
            
$resize 0;
        } elseif (!
is_array($operand2)) {
            list(
$matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand1);
            
$operand2 array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2));
            
$resize 0;
        }

        list(
$matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($operand1);
        list(
$matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($operand2);
        if ((
$matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
            
$resize 1;
        }

        if (
$resize == 2) {
            
//    Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
            
self::_resizeMatricesExtend($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
        } elseif (
$resize == 1) {
            
//    Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
            
self::_resizeMatricesShrink($operand1,$operand2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
        }
        return array( 
$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns);
    }    
//    function _checkMatrixOperands()


    /**
     * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0
     *
     * @param    mixed        &$matrix        matrix operand
     * @return    array        An array comprising the number of rows, and number of columns
     */
    
public static function _getMatrixDimensions(&$matrix) {
        
$matrixRows count($matrix);
        
$matrixColumns 0;
        foreach(
$matrix as $rowKey => $rowValue) {
            
$matrixColumns max(count($rowValue),$matrixColumns);
            if (!
is_array($rowValue)) {
                
$matrix[$rowKey] = array($rowValue);
            } else {
                
$matrix[$rowKey] = array_values($rowValue);
            }
        }
        
$matrix array_values($matrix);
        return array(
$matrixRows,$matrixColumns);
    }    
//    function _getMatrixDimensions()


    /**
     * Ensure that paired matrix operands are both matrices of the same size
     *
     * @param    mixed        &$matrix1        First matrix operand
     * @param    mixed        &$matrix2        Second matrix operand
     * @param    integer        $matrix1Rows    Row size of first matrix operand
     * @param    integer        $matrix1Columns    Column size of first matrix operand
     * @param    integer        $matrix2Rows    Row size of second matrix operand
     * @param    integer        $matrix2Columns    Column size of second matrix operand
     */
    
private static function _resizeMatricesShrink(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
        if ((
$matrix2Columns $matrix1Columns) || ($matrix2Rows $matrix1Rows)) {
            if (
$matrix2Rows $matrix1Rows) {
                for (
$i $matrix2Rows$i $matrix1Rows; ++$i) {
                    unset(
$matrix1[$i]);
                }
            }
            if (
$matrix2Columns $matrix1Columns) {
                for (
$i 0$i $matrix1Rows; ++$i) {
                    for (
$j $matrix2Columns$j $matrix1Columns; ++$j) {
                        unset(
$matrix1[$i][$j]);
                    }
                }
            }
        }

        if ((
$matrix1Columns $matrix2Columns) || ($matrix1Rows $matrix2Rows)) {
            if (
$matrix1Rows $matrix2Rows) {
                for (
$i $matrix1Rows$i $matrix2Rows; ++$i) {
                    unset(
$matrix2[$i]);
                }
            }
            if (
$matrix1Columns $matrix2Columns) {
                for (
$i 0$i $matrix2Rows; ++$i) {
                    for (
$j $matrix1Columns$j $matrix2Columns; ++$j) {
                        unset(
$matrix2[$i][$j]);
                    }
                }
            }
        }
    }    
//    function _resizeMatricesShrink()


    /**
     * Ensure that paired matrix operands are both matrices of the same size
     *
     * @param    mixed        &$matrix1    First matrix operand
     * @param    mixed        &$matrix2    Second matrix operand
     * @param    integer        $matrix1Rows    Row size of first matrix operand
     * @param    integer        $matrix1Columns    Column size of first matrix operand
     * @param    integer        $matrix2Rows    Row size of second matrix operand
     * @param    integer        $matrix2Columns    Column size of second matrix operand
     */
    
private static function _resizeMatricesExtend(&$matrix1,&$matrix2,$matrix1Rows,$matrix1Columns,$matrix2Rows,$matrix2Columns) {
        if ((
$matrix2Columns $matrix1Columns) || ($matrix2Rows $matrix1Rows)) {
            if (
$matrix2Columns $matrix1Columns) {
                for (
$i 0$i $matrix2Rows; ++$i) {
                    
$x $matrix2[$i][$matrix2Columns-1];
                    for (
$j $matrix2Columns$j $matrix1Columns; ++$j) {
                        
$matrix2[$i][$j] = $x;
                    }
                }
            }
            if (
$matrix2Rows $matrix1Rows) {
                
$x $matrix2[$matrix2Rows-1];
                for (
$i 0$i $matrix1Rows; ++$i) {
                    
$matrix2[$i] = $x;
                }
            }
        }

        if ((
$matrix1Columns $matrix2Columns) || ($matrix1Rows $matrix2Rows)) {
            if (
$matrix1Columns $matrix2Columns) {
                for (
$i 0$i $matrix1Rows; ++$i) {
                    
$x $matrix1[$i][$matrix1Columns-1];
                    for (
$j $matrix1Columns$j $matrix2Columns; ++$j) {
                        
$matrix1[$i][$j] = $x;
                    }
                }
            }
            if (
$matrix1Rows $matrix2Rows) {
                
$x $matrix1[$matrix1Rows-1];
                for (
$i 0$i $matrix2Rows; ++$i) {
                    
$matrix1[$i] = $x;
                }
            }
        }
    }    
//    function _resizeMatricesExtend()


    /**
     * Format details of an operand for display in the log (based on operand type)
     *
     * @param    mixed        $value    First matrix operand
     * @return    mixed
     */
    
private function _showValue($value) {
        if (
$this->_debugLog->getWriteDebugLog()) {
            
$testArray PHPExcel_Calculation_Functions::flattenArray($value);
            if (
count($testArray) == 1) {
                
$value array_pop($testArray);
            }

            if (
is_array($value)) {
                
$returnMatrix = array();
                
$pad $rpad ', ';
                foreach(
$value as $row) {
                    if (
is_array($row)) {
                        
$returnMatrix[] = implode($pad,array_map(array($this,'_showValue'),$row));
                        
$rpad '; ';
                    } else {
                        
$returnMatrix[] = $this->_showValue($row);
                    }
                }
                return 
'{ '.implode($rpad,$returnMatrix).' }';
            } elseif(
is_string($value) && (trim($value,'"') == $value)) {
                return 
'"'.$value.'"';
            } elseif(
is_bool($value)) {
                return (
$value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
            }
        }
        return 
PHPExcel_Calculation_Functions::flattenSingleValue($value);
    }    
//    function _showValue()


    /**
     * Format type and details of an operand for display in the log (based on operand type)
     *
     * @param    mixed        $value    First matrix operand
     * @return    mixed
     */
    
private function _showTypeDetails($value) {
        if (
$this->_debugLog->getWriteDebugLog()) {
            
$testArray PHPExcel_Calculation_Functions::flattenArray($value);
            if (
count($testArray) == 1) {
                
$value array_pop($testArray);
            }

            if (
$value === NULL) {
                return 
'a NULL value';
            } elseif (
is_float($value)) {
                
$typeString 'a floating point number';
            } elseif(
is_int($value)) {
                
$typeString 'an integer number';
            } elseif(
is_bool($value)) {
                
$typeString 'a boolean';
            } elseif(
is_array($value)) {
                
$typeString 'a matrix';
            } else {
                if (
$value == '') {
                    return 
'an empty string';
                } elseif (
$value{0} == '#') {
                    return 
'a '.$value.' error';
                } else {
                    
$typeString 'a string';
                }
            }
            return 
$typeString.' with a value of '.$this->_showValue($value);
        }
    }    
//    function _showTypeDetails()


    
private function _convertMatrixReferences($formula) {
        static 
$matrixReplaceFrom = array('{',';','}');
        static 
$matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))');

        
//    Convert any Excel matrix references to the MKMATRIX() function
        
if (strpos($formula,'{') !== FALSE) {
            
//    If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
            
if (strpos($formula,'"') !== FALSE) {
                
//    So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
                //        the formula
                
$temp explode('"',$formula);
                
//    Open and Closed counts used for trapping mismatched braces in the formula
                
$openCount $closeCount 0;
                
$i FALSE;
                foreach(
$temp as &$value) {
                    
//    Only count/replace in alternating array entries
                    
if ($i = !$i) {
                        
$openCount += substr_count($value,'{');
                        
$closeCount += substr_count($value,'}');
                        
$value str_replace($matrixReplaceFrom,$matrixReplaceTo,$value);
                    }
                }
                unset(
$value);
                
//    Then rebuild the formula string
                
$formula implode('"',$temp);
            } else {
                
//    If there's no quoted strings, then we do a simple count/replace
                
$openCount substr_count($formula,'{');
                
$closeCount substr_count($formula,'}');
                
$formula str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula);
            }
            
//    Trap for mismatched braces and trigger an appropriate error
            
if ($openCount $closeCount) {
                if (
$openCount 0) {
                    return 
$this->_raiseFormulaError("Formula Error: Mismatched matrix braces '}'");
                } else {
                    return 
$this->_raiseFormulaError("Formula Error: Unexpected '}' encountered");
                }
            } elseif (
$openCount $closeCount) {
                if (
$closeCount 0) {
                    return 
$this->_raiseFormulaError("Formula Error: Mismatched matrix braces '{'");
                } else {
                    return 
$this->_raiseFormulaError("Formula Error: Unexpected '{' encountered");
                }
            }
        }

        return 
$formula;
    }    
//    function _convertMatrixReferences()


    
private static function _mkMatrix() {
        return 
func_get_args();
    }    
//    function _mkMatrix()


    //    Binary Operators
    //    These operators always work on two values
    //    Array key is the operator, the value indicates whether this is a left or right associative operator
    
private static $_operatorAssociativity    = array(
        
'^' => 0,                                                            //    Exponentiation
        
'*' => 0'/' => 0,                                                 //    Multiplication and Division
        
'+' => 0'-' => 0,                                                    //    Addition and Subtraction
        
'&' => 0,                                                            //    Concatenation
        
'|' => 0':' => 0,                                                    //    Intersect and Range
        
'>' => 0'<' => 0'=' => 0'>=' => 0'<=' => 0'<>' => 0        //    Comparison
    
);

    
//    Comparison (Boolean) Operators
    //    These operators work on two values, but always return a boolean result
    
private static $_comparisonOperators    = array('>' => TRUE'<' => TRUE'=' => TRUE'>=' => TRUE'<=' => TRUE'<>' => TRUE);

    
//    Operator Precedence
    //    This list includes all valid operators, whether binary (including boolean) or unary (such as %)
    //    Array key is the operator, the value is its precedence
    
private static $_operatorPrecedence    = array(
        
':' => 8,                                                                //    Range
        
'|' => 7,                                                                //    Intersect
        
'~' => 6,                                                                //    Negation
        
'%' => 5,                                                                //    Percentage
        
'^' => 4,                                                                //    Exponentiation
        
'*' => 3'/' => 3,                                                     //    Multiplication and Division
        
'+' => 2'-' => 2,                                                        //    Addition and Subtraction
        
'&' => 1,                                                                //    Concatenation
        
'>' => 0'<' => 0'=' => 0'>=' => 0'<=' => 0'<>' => 0            //    Comparison
    
);

    
// Convert infix to postfix notation
    
private function _parseFormula($formulaPHPExcel_Cell $pCell NULL) {
        if ((
$formula $this->_convertMatrixReferences(trim($formula))) === FALSE) {
            return 
FALSE;
        }

        
//    If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
        //        so we store the parent worksheet so that we can re-attach it when necessary
        
$pCellParent = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;

        
$regexpMatchString '/^('.self::CALCULATION_REGEXP_FUNCTION.
                               
'|'.self::CALCULATION_REGEXP_CELLREF.
                               
'|'.self::CALCULATION_REGEXP_NUMBER.
                               
'|'.self::CALCULATION_REGEXP_STRING.
                               
'|'.self::CALCULATION_REGEXP_OPENBRACE.
                               
'|'.self::CALCULATION_REGEXP_NAMEDRANGE.
                               
'|'.self::CALCULATION_REGEXP_ERROR.
                             
')/si';

        
//    Start with initialisation
        
$index 0;
        
$stack = new PHPExcel_Calculation_Token_Stack;
        
$output = array();
        
$expectingOperator FALSE;                    //    We use this test in syntax-checking the expression to determine when a
                                                    //        - is a negation or + is a positive operator rather than an operation
        
$expectingOperand FALSE;                    //    We use this test in syntax-checking the expression to determine whether an operand
                                                    //        should be null in a function call
        //    The guts of the lexical parser
        //    Loop through the formula extracting each operator and operand in turn
        
while(TRUE) {
//echo 'Assessing Expression '.substr($formula, $index),PHP_EOL;
            
$opCharacter $formula{$index};    //    Get the first character of the value at the current index position
//echo 'Initial character of expression block is '.$opCharacter,PHP_EOL;
            
if ((isset(self::$_comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$_comparisonOperators[$formula{$index+1}]))) {
                
$opCharacter .= $formula{++$index};
//echo 'Initial character of expression block is comparison operator '.$opCharacter.PHP_EOL;
            
}

            
//    Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand
            
$isOperandOrFunction preg_match($regexpMatchStringsubstr($formula$index), $match);
//echo '$isOperandOrFunction is '.(($isOperandOrFunction) ? 'True' : 'False').PHP_EOL;
//var_dump($match);

            
if ($opCharacter == '-' && !$expectingOperator) {                //    Is it a negation instead of a minus?
//echo 'Element is a Negation operator',PHP_EOL;
                
$stack->push('Unary Operator','~');                            //    Put a negation on the stack
                
++$index;                                                    //        and drop the negation symbol
            
} elseif ($opCharacter == '%' && $expectingOperator) {
//echo 'Element is a Percentage operator',PHP_EOL;
                
$stack->push('Unary Operator','%');                            //    Put a percentage on the stack
                
++$index;
            } elseif (
$opCharacter == '+' && !$expectingOperator) {            //    Positive (unary plus rather than binary operator plus) can be discarded?
//echo 'Element is a Positive number, not Plus operator',PHP_EOL;
                
++$index;                                                    //    Drop the redundant plus symbol
            
} elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) {    //    We have to explicitly deny a tilde or pipe, because they are legal
                
return $this->_raiseFormulaError("Formula Error: Illegal character '~'");                //        on the stack but not in the input expression

            
} elseif ((isset(self::$_operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) {    //    Are we putting an operator on the stack?
//echo 'Element with value '.$opCharacter.' is an Operator',PHP_EOL;
                
while($stack->count() > &&
                    (
$o2 $stack->last()) &&
                    isset(
self::$_operators[$o2['value']]) &&
                    @(
self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
                    
$output[] = $stack->pop();                                //    Swap operands and higher precedence operators from the stack to the output
                
}
                
$stack->push('Binary Operator',$opCharacter);    //    Finally put our current operator onto the stack
                
++$index;
                
$expectingOperator FALSE;

            } elseif (
$opCharacter == ')' && $expectingOperator) {            //    Are we expecting to close a parenthesis?
//echo 'Element is a Closing bracket',PHP_EOL;
                
$expectingOperand FALSE;
                while ((
$o2 $stack->pop()) && $o2['value'] != '(') {        //    Pop off the stack back to the last (
                    
if ($o2 === NULL) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
                    else 
$output[] = $o2;
                }
                
$d $stack->last(2);
                if (
preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i'$d['value'], $matches)) {    //    Did this parenthesis just close a function?
                    
$functionName $matches[1];                                        //    Get the function name
//echo 'Closed Function is '.$functionName,PHP_EOL;
                    
$d $stack->pop();
                    
$argumentCount $d['value'];        //    See how many arguments there were (argument count is the next value stored on the stack)
//if ($argumentCount == 0) {
//    echo 'With no arguments',PHP_EOL;
//} elseif ($argumentCount == 1) {
//    echo 'With 1 argument',PHP_EOL;
//} else {
//    echo 'With '.$argumentCount.' arguments',PHP_EOL;
//}
                    
$output[] = $d;                        //    Dump the argument count on the output
                    
$output[] = $stack->pop();            //    Pop the function and push onto the output
                    
if (isset(self::$_controlFunctions[$functionName])) {
//echo 'Built-in function '.$functionName,PHP_EOL;
                        
$expectedArgumentCount self::$_controlFunctions[$functionName]['argumentCount'];
                        
$functionCall self::$_controlFunctions[$functionName]['functionCall'];
                    } elseif (isset(
self::$_PHPExcelFunctions[$functionName])) {
//echo 'PHPExcel function '.$functionName,PHP_EOL;
                        
$expectedArgumentCount self::$_PHPExcelFunctions[$functionName]['argumentCount'];
                        
$functionCall self::$_PHPExcelFunctions[$functionName]['functionCall'];
                    } else {    
// did we somehow push a non-function on the stack? this should never happen
                        
return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
                    }
                    
//    Check the argument count
                    
$argumentCountError FALSE;
                    if (
is_numeric($expectedArgumentCount)) {
                        if (
$expectedArgumentCount 0) {
//echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount),PHP_EOL;
                            
if ($argumentCount abs($expectedArgumentCount)) {
                                
$argumentCountError TRUE;
                                
$expectedArgumentCountString 'no more than '.abs($expectedArgumentCount);
                            }
                        } else {
//echo '$expectedArgumentCount is numeric '.$expectedArgumentCount,PHP_EOL;
                            
if ($argumentCount != $expectedArgumentCount) {
                                
$argumentCountError TRUE;
                                
$expectedArgumentCountString $expectedArgumentCount;
                            }
                        }
                    } elseif (
$expectedArgumentCount != '*') {
                        
$isOperandOrFunction preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch);
//print_r($argMatch);
//echo PHP_EOL;
                        
switch ($argMatch[2]) {
                            case 
'+' :
                                if (
$argumentCount $argMatch[1]) {
                                    
$argumentCountError TRUE;
                                    
$expectedArgumentCountString $argMatch[1].' or more ';
                                }
                                break;
                            case 
'-' :
                                if ((
$argumentCount $argMatch[1]) || ($argumentCount $argMatch[3])) {
                                    
$argumentCountError TRUE;
                                    
$expectedArgumentCountString 'between '.$argMatch[1].' and '.$argMatch[3];
                                }
                                break;
                            case 
',' :
                                if ((
$argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
                                    
$argumentCountError TRUE;
                                    
$expectedArgumentCountString 'either '.$argMatch[1].' or '.$argMatch[3];
                                }
                                break;
                        }
                    }
                    if (
$argumentCountError) {
                        return 
$this->_raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString." expected");
                    }
                }
                ++
$index;

            } elseif (
$opCharacter == ',') {            //    Is this the separator for function arguments?
//echo 'Element is a Function argument separator',PHP_EOL;
                
while (($o2 $stack->pop()) && $o2['value'] != '(') {        //    Pop off the stack back to the last (
                    
if ($o2 === NULL) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
                    else 
$output[] = $o2;    // pop the argument expression stuff and push onto the output
                
}
                
//    If we've a comma when we're expecting an operand, then what we actually have is a null operand;
                //        so push a null onto the stack
                
if (($expectingOperand) || (!$expectingOperator)) {
                    
$output[] = array('type' => 'NULL Value''value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
                }
                
// make sure there was a function
                
$d $stack->last(2);
                if (!
preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i'$d['value'], $matches))
                    return 
$this->_raiseFormulaError("Formula Error: Unexpected ,");
                
$d $stack->pop();
                
$stack->push($d['type'],++$d['value'],$d['reference']);    // increment the argument count
                
$stack->push('Brace''(');    // put the ( back on, we'll need to pop back to it again
                
$expectingOperator FALSE;
                
$expectingOperand TRUE;
                ++
$index;

            } elseif (
$opCharacter == '(' && !$expectingOperator) {
//                echo 'Element is an Opening Bracket<br />';
                
$stack->push('Brace''(');
                ++
$index;

            } elseif (
$isOperandOrFunction && !$expectingOperator) {    // do we now have a function/variable/number?
                
$expectingOperator TRUE;
                
$expectingOperand FALSE;
                
$val $match[1];
                
$length strlen($val);
//                echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />';

                
if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i'$val$matches)) {
                    
$val preg_replace('/\s/u','',$val);
//                    echo 'Element '.$val.' is a Function<br />';
                    
if (isset(self::$_PHPExcelFunctions[strtoupper($matches[1])]) || isset(self::$_controlFunctions[strtoupper($matches[1])])) {    // it's a function
                        
$stack->push('Function'strtoupper($val));
                        
$ax preg_match('/^\s*(\s*\))/ui'substr($formula$index+$length), $amatch);
                        if (
$ax) {
                            
$stack->push('Operand Count for Function '.strtoupper($val).')'0);
                            
$expectingOperator TRUE;
                        } else {
                            
$stack->push('Operand Count for Function '.strtoupper($val).')'1);
                            
$expectingOperator FALSE;
                        }
                        
$stack->push('Brace''(');
                    } else {    
// it's a var w/ implicit multiplication
                        
$output[] = array('type' => 'Value''value' => $matches[1], 'reference' => NULL);
                    }
                } elseif (
preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i'$val$matches)) {
//                    echo 'Element '.$val.' is a Cell reference<br />';
                    //    Watch for this case-change when modifying to allow cell references in different worksheets...
                    //    Should only be applied to the actual cell column, not the worksheet name

                    //    If the last entry on the stack was a : operator, then we have a cell range reference
                    
$testPrevOp $stack->last(1);
                    if (
$testPrevOp['value'] == ':') {
                        
//    If we have a worksheet reference, then we're playing with a 3D reference
                        
if ($matches[2] == '') {
                            
//    Otherwise, we 'inherit' the worksheet reference from the start cell reference
                            //    The start of the cell range reference should be the last entry in $output
                            
$startCellRef $output[count($output)-1]['value'];
                            
preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i'$startCellRef$startMatches);
                            if (
$startMatches[2] > '') {
                                
$val $startMatches[2].'!'.$val;
                            }
                        } else {
                            return 
$this->_raiseFormulaError("3D Range references are not yet supported");
                        }
                    }

                    
$output[] = array('type' => 'Cell Reference''value' => $val'reference' => $val);
//                    $expectingOperator = FALSE;
                
} else {    // it's a variable, constant, string, number or boolean
//                    echo 'Element is a Variable, Constant, String, Number or Boolean<br />';
                    //    If the last entry on the stack was a : operator, then we may have a row or column range reference
                    
$testPrevOp $stack->last(1);
                    if (
$testPrevOp['value'] == ':') {
                        
$startRowColRef $output[count($output)-1]['value'];
                        
$rangeWS1 '';
                        if (
strpos('!',$startRowColRef) !== FALSE) {
                            list(
$rangeWS1,$startRowColRef) = explode('!',$startRowColRef);
                        }
                        if (
$rangeWS1 != ''$rangeWS1 .= '!';
                        
$rangeWS2 $rangeWS1;
                        if (
strpos('!',$val) !== FALSE) {
                            list(
$rangeWS2,$val) = explode('!',$val);
                        }
                        if (
$rangeWS2 != ''$rangeWS2 .= '!';
                        if ((
is_integer($startRowColRef)) && (ctype_digit($val)) &&
                            (
$startRowColRef <= 1048576) && ($val <= 1048576)) {
                            
//    Row range
                            
$endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestColumn() : 'XFD';    //    Max 16,384 columns for Excel2007
                            
$output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef;
                            
$val $rangeWS2.$endRowColRef.$val;
                        } elseif ((
ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
                            (
strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
                            
//    Column range
                            
$endRowColRef = ($pCellParent !== NULL) ? $pCellParent->getHighestRow() : 1048576;        //    Max 1,048,576 rows for Excel2007
                            
$output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1';
                            
$val $rangeWS2.$val.$endRowColRef;
                        }
                    }

                    
$localeConstant FALSE;
                    if (
$opCharacter == '"') {
//                        echo 'Element is a String<br />';
                        //    UnEscape any quotes within the string
                        
$val self::_wrapResult(str_replace('""','"',self::_unwrapResult($val)));
                    } elseif (
is_numeric($val)) {
//                        echo 'Element is a Number<br />';
                        
if ((strpos($val,'.') !== FALSE) || (stripos($val,'e') !== FALSE) || ($val PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
//                            echo 'Casting '.$val.' to float<br />';
                            
$val = (float) $val;
                        } else {
//                            echo 'Casting '.$val.' to integer<br />';
                            
$val = (integer) $val;
                        }
                    } elseif (isset(
self::$_ExcelConstants[trim(strtoupper($val))])) {
                        
$excelConstant trim(strtoupper($val));
//                        echo 'Element '.$excelConstant.' is an Excel Constant<br />';
                        
$val self::$_ExcelConstants[$excelConstant];
                    } elseif ((
$localeConstant array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== FALSE) {
//                        echo 'Element '.$localeConstant.' is an Excel Constant<br />';
                        
$val self::$_ExcelConstants[$localeConstant];
                    }
                    
$details = array('type' => 'Value''value' => $val'reference' => NULL);
                    if (
$localeConstant) { $details['localeValue'] = $localeConstant; }
                    
$output[] = $details;
                }
                
$index += $length;

            } elseif (
$opCharacter == '$') {    // absolute row or column range
                
++$index;
            } elseif (
$opCharacter == ')') {    // miscellaneous error checking
                
if ($expectingOperand) {
                    
$output[] = array('type' => 'NULL Value''value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
                    
$expectingOperand FALSE;
                    
$expectingOperator TRUE;
                } else {
                    return 
$this->_raiseFormulaError("Formula Error: Unexpected ')'");
                }
            } elseif (isset(
self::$_operators[$opCharacter]) && !$expectingOperator) {
                return 
$this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
            } else {    
// I don't even want to know what you did to get here
                
return $this->_raiseFormulaError("Formula Error: An unexpected error occured");
            }
            
//    Test for end of formula string
            
if ($index == strlen($formula)) {
                
//    Did we end with an operator?.
                //    Only valid for the % unary operator
                
if ((isset(self::$_operators[$opCharacter])) && ($opCharacter != '%')) {
                    return 
$this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
                } else {
                    break;
                }
            }
            
//    Ignore white space
            
while (($formula{$index} == "\n") || ($formula{$index} == "\r")) {
                ++
$index;
            }
            if (
$formula{$index} == ' ') {
                while (
$formula{$index} == ' ') {
                    ++
$index;
                }
                
//    If we're expecting an operator, but only have a space between the previous and next operands (and both are
                //        Cell References) then we have an INTERSECTION operator
//                echo 'Possible Intersect Operator<br />';
                
if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/Ui'substr($formula$index), $match)) &&
                    (
$output[count($output)-1]['type'] == 'Cell Reference')) {
//                    echo 'Element is an Intersect Operator<br />';
                    
while($stack->count() > &&
                        (
$o2 $stack->last()) &&
                        isset(
self::$_operators[$o2['value']]) &&
                        @(
self::$_operatorAssociativity[$opCharacter] ? self::$_operatorPrecedence[$opCharacter] < self::$_operatorPrecedence[$o2['value']] : self::$_operatorPrecedence[$opCharacter] <= self::$_operatorPrecedence[$o2['value']])) {
                        
$output[] = $stack->pop();                                //    Swap operands and higher precedence operators from the stack to the output
                    
}
                    
$stack->push('Binary Operator','|');    //    Put an Intersect Operator on the stack
                    
$expectingOperator FALSE;
                }
            }
        }

        while ((
$op $stack->pop()) !== NULL) {    // pop everything off the stack and push onto output
            
if ((is_array($op) && $op['value'] == '(') || ($op === '('))
                return 
$this->_raiseFormulaError("Formula Error: Expecting ')'");    // if there are any opening braces on the stack, then braces were unbalanced
            
$output[] = $op;
        }
        return 
$output;
    }    
//    function _parseFormula()


    
private static function _dataTestReference(&$operandData)
    {
        
$operand $operandData['value'];
        if ((
$operandData['reference'] === NULL) && (is_array($operand))) {
            
$rKeys array_keys($operand);
            
$rowKey array_shift($rKeys);
            
$cKeys array_keys(array_keys($operand[$rowKey]));
            
$colKey array_shift($cKeys);
            if (
ctype_upper($colKey)) {
                
$operandData['reference'] = $colKey.$rowKey;
            }
        }
        return 
$operand;
    }

    
// evaluate postfix notation
    
private function _processTokenStack($tokens$cellID NULLPHPExcel_Cell $pCell NULL) {
        if (
$tokens == FALSE) return FALSE;

        
//    If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent cell collection),
        //        so we store the parent cell collection so that we can re-attach it when necessary
        
$pCellWorksheet = ($pCell !== NULL) ? $pCell->getWorksheet() : NULL;
        
$pCellParent = ($pCell !== NULL) ? $pCell->getParent() : null;
        
$stack = new PHPExcel_Calculation_Token_Stack;

        
//    Loop through each token in turn
        
foreach ($tokens as $tokenData) {
//            print_r($tokenData);
//            echo '<br />';
            
$token $tokenData['value'];
//            echo '<b>Token is '.$token.'</b><br />';
            // if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
            
if (isset(self::$_binaryOperators[$token])) {
//                echo 'Token is a binary operator<br />';
                //    We must have two operands, error if we don't
                
if (($operand2Data $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
                if ((
$operand1Data $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');

                
$operand1 self::_dataTestReference($operand1Data);
                
$operand2 self::_dataTestReference($operand2Data);

                
//    Log what we're doing
                
if ($token == ':') {
                    
$this->_debugLog->writeDebugLog('Evaluating Range '$this->_showValue($operand1Data['reference']), ' '$token' '$this->_showValue($operand2Data['reference']));
                } else {
                    
$this->_debugLog->writeDebugLog('Evaluating '$this->_showValue($operand1), ' '$token' '$this->_showValue($operand2));
                }

                
//    Process the operation in the appropriate manner
                
switch ($token) {
                    
//    Comparison (Boolean) Operators
                    
case '>'    :            //    Greater than
                    
case '<'    :            //    Less than
                    
case '>='    :            //    Greater than or Equal to
                    
case '<='    :            //    Less than or Equal to
                    
case '='    :            //    Equality
                    
case '<>'    :            //    Inequality
                        
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operand2,$token,$stack);
                        break;
                    
//    Binary Operators
                    
case ':'    :            //    Range
                        
$sheet1 $sheet2 '';
                        if (
strpos($operand1Data['reference'],'!') !== FALSE) {
                            list(
$sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']);
                        } else {
                            
$sheet1 = ($pCellParent !== NULL) ? $pCellWorksheet->getTitle() : '';
                        }
                        if (
strpos($operand2Data['reference'],'!') !== FALSE) {
                            list(
$sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']);
                        } else {
                            
$sheet2 $sheet1;
                        }
                        if (
$sheet1 == $sheet2) {
                            if (
$operand1Data['reference'] === NULL) {
                                if ((
trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) {
                                    
$operand1Data['reference'] = $pCell->getColumn().$operand1Data['value'];
                                } elseif (
trim($operand1Data['reference']) == '') {
                                    
$operand1Data['reference'] = $pCell->getCoordinate();
                                } else {
                                    
$operand1Data['reference'] = $operand1Data['value'].$pCell->getRow();
                                }
                            }
                            if (
$operand2Data['reference'] === NULL) {
                                if ((
trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) {
                                    
$operand2Data['reference'] = $pCell->getColumn().$operand2Data['value'];
                                } elseif (
trim($operand2Data['reference']) == '') {
                                    
$operand2Data['reference'] = $pCell->getCoordinate();
                                } else {
                                    
$operand2Data['reference'] = $operand2Data['value'].$pCell->getRow();
                                }
                            }

                            
$oData array_merge(explode(':',$operand1Data['reference']),explode(':',$operand2Data['reference']));
                            
$oCol $oRow = array();
                            foreach(
$oData as $oDatum) {
                                
$oCR PHPExcel_Cell::coordinateFromString($oDatum);
                                
$oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1;
                                
$oRow[] = $oCR[1];
                            }
                            
$cellRef PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
                            if (
$pCellParent !== NULL) {
                                
$cellValue $this->extractCellRange($cellRef$this->_workbook->getSheetByName($sheet1), FALSE);
                            } else {
                                return 
$this->_raiseFormulaError('Unable to access Cell Reference');
                            }
                            
$stack->push('Cell Reference',$cellValue,$cellRef);
                        } else {
                            
$stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
                        }

                        break;
                    case 
'+'    :            //    Addition
                        
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'plusEquals',$stack);
                        break;
                    case 
'-'    :            //    Subtraction
                        
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'minusEquals',$stack);
                        break;
                    case 
'*'    :            //    Multiplication
                        
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayTimesEquals',$stack);
                        break;
                    case 
'/'    :            //    Division
                        
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayRightDivide',$stack);
                        break;
                    case 
'^'    :            //    Exponential
                        
$this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'power',$stack);
                        break;
                    case 
'&'    :            //    Concatenation
                        //    If either of the operands is a matrix, we need to treat them both as matrices
                        //        (converting the other operand to a matrix if need be); then perform the required
                        //        matrix operation
                        
if (is_bool($operand1)) {
                            
$operand1 = ($operand1) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
                        }
                        if (
is_bool($operand2)) {
                            
$operand2 = ($operand2) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
                        }
                        if ((
is_array($operand1)) || (is_array($operand2))) {
                            
//    Ensure that both operands are arrays/matrices
                            
self::_checkMatrixOperands($operand1,$operand2,2);
                            try {
                                
//    Convert operand 1 from a PHP array to a matrix
                                
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
                                
//    Perform the required operation against the operand 1 matrix, passing in operand 2
                                
$matrixResult $matrix->concat($operand2);
                                
$result $matrixResult->getArray();
                            } catch (
PHPExcel_Exception $ex) {
                                
$this->_debugLog->writeDebugLog('JAMA Matrix Exception: '$ex->getMessage());
                                
$result '#VALUE!';
                            }
                        } else {
                            
$result '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
                        }
                        
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($result));
                        
$stack->push('Value',$result);
                        break;
                    case 
'|'    :            //    Intersect
                        
$rowIntersect array_intersect_key($operand1,$operand2);
                        
$cellIntersect $oCol $oRow = array();
                        foreach(
array_keys($rowIntersect) as $row) {
                            
$oRow[] = $row;
                            foreach(
$rowIntersect[$row] as $col => $data) {
                                
$oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1;
                                
$cellIntersect[$row] = array_intersect_key($operand1[$row],$operand2[$row]);
                            }
                        }
                        
$cellRef PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
                        
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($cellIntersect));
                        
$stack->push('Value',$cellIntersect,$cellRef);
                        break;
                }

            
// if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
            
} elseif (($token === '~') || ($token === '%')) {
//                echo 'Token is a unary operator<br />';
                
if (($arg $stack->pop()) === NULL) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
                
$arg $arg['value'];
                if (
$token === '~') {
//                    echo 'Token is a negation operator<br />';
                    
$this->_debugLog->writeDebugLog('Evaluating Negation of '$this->_showValue($arg));
                    
$multiplier = -1;
                } else {
//                    echo 'Token is a percentile operator<br />';
                    
$this->_debugLog->writeDebugLog('Evaluating Percentile of '$this->_showValue($arg));
                    
$multiplier 0.01;
                }
                if (
is_array($arg)) {
                    
self::_checkMatrixOperands($arg,$multiplier,2);
                    try {
                        
$matrix1 = new PHPExcel_Shared_JAMA_Matrix($arg);
                        
$matrixResult $matrix1->arrayTimesEquals($multiplier);
                        
$result $matrixResult->getArray();
                    } catch (
PHPExcel_Exception $ex) {
                        
$this->_debugLog->writeDebugLog('JAMA Matrix Exception: '$ex->getMessage());
                        
$result '#VALUE!';
                    }
                    
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($result));
                    
$stack->push('Value',$result);
                } else {
                    
$this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack);
                }

            } elseif (
preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i'$token$matches)) {
                
$cellRef NULL;
//                echo 'Element '.$token.' is a Cell reference<br />';
                
if (isset($matches[8])) {
//                    echo 'Reference is a Range of cells<br />';
                    
if ($pCell === NULL) {
//                        We can't access the range, so return a REF error
                        
$cellValue PHPExcel_Calculation_Functions::REF();
                    } else {
                        
$cellRef $matches[6].$matches[7].':'.$matches[9].$matches[10];
                        if (
$matches[2] > '') {
                            
$matches[2] = trim($matches[2],"\"'");
                            if ((
strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) {
                                
//    It's a Reference to an external workbook (not currently supported)
                                
return $this->_raiseFormulaError('Unable to access External Workbook');
                            }
                            
$matches[2] = trim($matches[2],"\"'");
//                            echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
                            
$this->_debugLog->writeDebugLog('Evaluating Cell Range '$cellRef' in worksheet '$matches[2]);
                            if (
$pCellParent !== NULL) {
                                
$cellValue $this->extractCellRange($cellRef$this->_workbook->getSheetByName($matches[2]), FALSE);
                            } else {
                                return 
$this->_raiseFormulaError('Unable to access Cell Reference');
                            }
                            
$this->_debugLog->writeDebugLog('Evaluation Result for cells '$cellRef' in worksheet '$matches[2], ' is '$this->_showTypeDetails($cellValue));
//                            $cellRef = $matches[2].'!'.$cellRef;
                        
} else {
//                            echo '$cellRef='.$cellRef.' in current worksheet<br />';
                            
$this->_debugLog->writeDebugLog('Evaluating Cell Range '$cellRef' in current worksheet');
                            if (
$pCellParent !== NULL) {
                                
$cellValue $this->extractCellRange($cellRef$pCellWorksheetFALSE);
                            } else {
                                return 
$this->_raiseFormulaError('Unable to access Cell Reference');
                            }
                            
$this->_debugLog->writeDebugLog('Evaluation Result for cells '$cellRef' is '$this->_showTypeDetails($cellValue));
                        }
                    }
                } else {
//                    echo 'Reference is a single Cell<br />';
                    
if ($pCell === NULL) {
//                        We can't access the cell, so return a REF error
                        
$cellValue PHPExcel_Calculation_Functions::REF();
                    } else {
                        
$cellRef $matches[6].$matches[7];
                        if (
$matches[2] > '') {
                            
$matches[2] = trim($matches[2],"\"'");
                            if ((
strpos($matches[2],'[') !== FALSE) || (strpos($matches[2],']') !== FALSE)) {
                                
//    It's a Reference to an external workbook (not currently supported)
                                
return $this->_raiseFormulaError('Unable to access External Workbook');
                            }
//                            echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
                            
$this->_debugLog->writeDebugLog('Evaluating Cell '$cellRef' in worksheet '$matches[2]);
                            if (
$pCellParent !== NULL) {
                                
$cellSheet $this->_workbook->getSheetByName($matches[2]);
                                if (
$cellSheet && $cellSheet->cellExists($cellRef)) {
                                    
$cellValue $this->extractCellRange($cellRef$this->_workbook->getSheetByName($matches[2]), FALSE);
                                    
$pCell->attach($pCellParent);
                                } else {
                                    
$cellValue NULL;
                                }
                            } else {
                                return 
$this->_raiseFormulaError('Unable to access Cell Reference');
                            }
                            
$this->_debugLog->writeDebugLog('Evaluation Result for cell '$cellRef' in worksheet '$matches[2], ' is '$this->_showTypeDetails($cellValue));
//                            $cellRef = $matches[2].'!'.$cellRef;
                        
} else {
//                            echo '$cellRef='.$cellRef.' in current worksheet<br />';
                            
$this->_debugLog->writeDebugLog('Evaluating Cell '$cellRef' in current worksheet');
                            if (
$pCellParent->isDataSet($cellRef)) {
                                
$cellValue $this->extractCellRange($cellRef$pCellWorksheetFALSE);
                                
$pCell->attach($pCellParent);
                            } else {
                                
$cellValue NULL;
                            }
                            
$this->_debugLog->writeDebugLog('Evaluation Result for cell '$cellRef' is '$this->_showTypeDetails($cellValue));
                        }
                    }
                }
                
$stack->push('Value',$cellValue,$cellRef);

            
// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
            
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i'$token$matches)) {
//                echo 'Token is a function<br />';
                
$functionName $matches[1];
                
$argCount $stack->pop();
                
$argCount $argCount['value'];
                if (
$functionName != 'MKMATRIX') {
                    
$this->_debugLog->writeDebugLog('Evaluating Function 'self::_localeFunc($functionName), '() with ', (($argCount == 0) ? 'no' $argCount), ' argument', (($argCount == 1) ? '' 's'));
                }
                if ((isset(
self::$_PHPExcelFunctions[$functionName])) || (isset(self::$_controlFunctions[$functionName]))) {    // function
                    
if (isset(self::$_PHPExcelFunctions[$functionName])) {
                        
$functionCall self::$_PHPExcelFunctions[$functionName]['functionCall'];
                        
$passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
                        
$passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
                    } elseif (isset(
self::$_controlFunctions[$functionName])) {
                        
$functionCall self::$_controlFunctions[$functionName]['functionCall'];
                        
$passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
                        
$passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
                    }
                    
// get the arguments for this function
//                    echo 'Function '.$functionName.' expects '.$argCount.' arguments<br />';
                    
$args $argArrayVals = array();
                    for (
$i 0$i $argCount; ++$i) {
                        
$arg $stack->pop();
                        
$a $argCount $i 1;
                        if ((
$passByReference) &&
                            (isset(
self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
                            (
self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
                            if (
$arg['reference'] === NULL) {
                                
$args[] = $cellID;
                                if (
$functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($cellID); }
                            } else {
                                
$args[] = $arg['reference'];
                                if (
$functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['reference']); }
                            }
                        } else {
                            
$args[] = self::_unwrapResult($arg['value']);
                            if (
$functionName != 'MKMATRIX') { $argArrayVals[] = $this->_showValue($arg['value']); }
                        }
                    }
                    
//    Reverse the order of the arguments
                    
krsort($args);
                    if ((
$passByReference) && ($argCount == 0)) {
                        
$args[] = $cellID;
                        
$argArrayVals[] = $this->_showValue($cellID);
                    }
//                    echo 'Arguments are: ';
//                    print_r($args);
//                    echo '<br />';
                    
if ($functionName != 'MKMATRIX') {
                        if (
$this->_debugLog->getWriteDebugLog()) {
                            
krsort($argArrayVals);
                            
$this->_debugLog->writeDebugLog('Evaluating 'self::_localeFunc($functionName), '( 'implode(self::$_localeArgumentSeparator.' ',PHPExcel_Calculation_Functions::flattenArray($argArrayVals)), ' )');
                        }
                    }
                    
//    Process each argument in turn, building the return value as an array
//                    if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) {
//                        $operand1 = $args[1];
//                        $this->_debugLog->writeDebugLog('Argument is a matrix: ', $this->_showValue($operand1));
//                        $result = array();
//                        $row = 0;
//                        foreach($operand1 as $args) {
//                            if (is_array($args)) {
//                                foreach($args as $arg) {
//                                    $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($arg), ' )');
//                                    $r = call_user_func_array($functionCall,$arg);
//                                    $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
//                                    $result[$row][] = $r;
//                                }
//                                ++$row;
//                            } else {
//                                $this->_debugLog->writeDebugLog('Evaluating ', self::_localeFunc($functionName), '( ', $this->_showValue($args), ' )');
//                                $r = call_user_func_array($functionCall,$args);
//                                $this->_debugLog->writeDebugLog('Evaluation Result for ', self::_localeFunc($functionName), '() function call is ', $this->_showTypeDetails($r));
//                                $result[] = $r;
//                            }
//                        }
//                    } else {
                    //    Process the argument with the appropriate function call
                        
if ($passCellReference) {
                            
$args[] = $pCell;
                        }
                        if (
strpos($functionCall,'::') !== FALSE) {
                            
$result call_user_func_array(explode('::',$functionCall),$args);
                        } else {
                            foreach(
$args as &$arg) {
                                
$arg PHPExcel_Calculation_Functions::flattenSingleValue($arg);
                            }
                            unset(
$arg);
                            
$result call_user_func_array($functionCall,$args);
                        }
//                    }
                    
if ($functionName != 'MKMATRIX') {
                        
$this->_debugLog->writeDebugLog('Evaluation Result for 'self::_localeFunc($functionName), '() function call is '$this->_showTypeDetails($result));
                    }
                    
$stack->push('Value',self::_wrapResult($result));
                }

            } else {
                
// if the token is a number, boolean, string or an Excel error, push it onto the stack
                
if (isset(self::$_ExcelConstants[strtoupper($token)])) {
                    
$excelConstant strtoupper($token);
//                    echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
                    
$stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
                    
$this->_debugLog->writeDebugLog('Evaluating Constant '$excelConstant' as '$this->_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
                } elseif ((
is_numeric($token)) || ($token === NULL) || (is_bool($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
//                    echo 'Token is a number, boolean, string, null or an Excel error<br />';
                    
$stack->push('Value',$token);
                
// if the token is a named range, push the named range name onto the stack
                
} elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i'$token$matches)) {
//                    echo 'Token is a named range<br />';
                    
$namedRange $matches[6];
//                    echo 'Named Range is '.$namedRange.'<br />';
                    
$this->_debugLog->writeDebugLog('Evaluating Named Range '$namedRange);
                    
$cellValue $this->extractNamedRange($namedRange, ((NULL !== $pCell) ? $pCellWorksheet NULL), FALSE);
                    
$pCell->attach($pCellParent);
                    
$this->_debugLog->writeDebugLog('Evaluation Result for named range '$namedRange' is '$this->_showTypeDetails($cellValue));
                    
$stack->push('Named Range',$cellValue,$namedRange);
                } else {
                    return 
$this->_raiseFormulaError("undefined variable '$token'");
                }
            }
        }
        
// when we're out of tokens, the stack should have a single element, the final result
        
if ($stack->count() != 1) return $this->_raiseFormulaError("internal error");
        
$output $stack->pop();
        
$output $output['value'];

//        if ((is_array($output)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
//            return array_shift(PHPExcel_Calculation_Functions::flattenArray($output));
//        }
        
return $output;
    }    
//    function _processTokenStack()


    
private function _validateBinaryOperand($cellID, &$operand, &$stack) {
        if (
is_array($operand)) {
            if ((
count($operandCOUNT_RECURSIVE) - count($operand)) == 1) {
                do {
                    
$operand array_pop($operand);
                } while (
is_array($operand));
            }
        }
        
//    Numbers, matrices and booleans can pass straight through, as they're already valid
        
if (is_string($operand)) {
            
//    We only need special validations for the operand if it is a string
            //    Start by stripping off the quotation marks we use to identify true excel string values internally
            
if ($operand '' && $operand{0} == '"') { $operand self::_unwrapResult($operand); }
            
//    If the string is a numeric value, we treat it as a numeric, so no further testing
            
if (!is_numeric($operand)) {
                
//    If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
                
if ($operand '' && $operand{0} == '#') {
                    
$stack->push('Value'$operand);
                    
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($operand));
                    return 
FALSE;
                } elseif (!
PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
                    
//    If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
                    
$stack->push('Value''#VALUE!');
                    
$this->_debugLog->writeDebugLog('Evaluation Result is a '$this->_showTypeDetails('#VALUE!'));
                    return 
FALSE;
                }
            }
        }

        
//    return a true if the value of the operand is one that we can use in normal binary operations
        
return TRUE;
    }    
//    function _validateBinaryOperand()


    
private function _executeBinaryComparisonOperation($cellID$operand1$operand2$operation, &$stack$recursingArrays=FALSE) {
        
//    If we're dealing with matrix operations, we want a matrix result
        
if ((is_array($operand1)) || (is_array($operand2))) {
            
$result = array();
            if ((
is_array($operand1)) && (!is_array($operand2))) {
                foreach(
$operand1 as $x => $operandData) {
                    
$this->_debugLog->writeDebugLog('Evaluating Comparison '$this->_showValue($operandData), ' '$operation' '$this->_showValue($operand2));
                    
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
                    
$r $stack->pop();
                    
$result[$x] = $r['value'];
                }
            } elseif ((!
is_array($operand1)) && (is_array($operand2))) {
                foreach(
$operand2 as $x => $operandData) {
                    
$this->_debugLog->writeDebugLog('Evaluating Comparison '$this->_showValue($operand1), ' '$operation' '$this->_showValue($operandData));
                    
$this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
                    
$r $stack->pop();
                    
$result[$x] = $r['value'];
                }
            } else {
                if (!
$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
                foreach(
$operand1 as $x => $operandData) {
                    
$this->_debugLog->writeDebugLog('Evaluating Comparison '$this->_showValue($operandData), ' '$operation' '$this->_showValue($operand2[$x]));
                    
$this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,TRUE);
                    
$r $stack->pop();
                    
$result[$x] = $r['value'];
                }
            }
            
//    Log the result details
            
$this->_debugLog->writeDebugLog('Comparison Evaluation Result is '$this->_showTypeDetails($result));
            
//    And push the result onto the stack
            
$stack->push('Array',$result);
            return 
TRUE;
        }

        
//    Simple validate the two operands if they are string values
        
if (is_string($operand1) && $operand1 '' && $operand1{0} == '"') { $operand1 self::_unwrapResult($operand1); }
        if (
is_string($operand2) && $operand2 '' && $operand2{0} == '"') { $operand2 self::_unwrapResult($operand2); }

        
// Use case insensitive comparaison if not OpenOffice mode
        
if (PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE)
        {
            if (
is_string($operand1)) {
                
$operand1 strtoupper($operand1);
            }

            if (
is_string($operand2)) {
                
$operand2 strtoupper($operand2);
            }
        }

        
$useLowercaseFirstComparison is_string($operand1) && is_string($operand2) && PHPExcel_Calculation_Functions::getCompatibilityMode() == PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE;

        
//    execute the necessary operation
        
switch ($operation) {
            
//    Greater than
            
case '>':
                if (
$useLowercaseFirstComparison) {
                    
$result $this->strcmpLowercaseFirst($operand1$operand2) > 0;
                } else {
                    
$result = ($operand1 $operand2);
                }
                break;
            
//    Less than
            
case '<':
                if (
$useLowercaseFirstComparison) {
                    
$result $this->strcmpLowercaseFirst($operand1$operand2) < 0;
                } else {
                    
$result = ($operand1 $operand2);
                }
                break;
            
//    Equality
            
case '=':
                if (
is_numeric($operand1) && is_numeric($operand2)) {
                    
$result = (abs($operand1 $operand2) < $this->delta);
                } else {
                    
$result strcmp($operand1$operand2) == 0;
                }
                break;
            
//    Greater than or equal
            
case '>=':
                if (
is_numeric($operand1) && is_numeric($operand2)) {
                    
$result = ((abs($operand1 $operand2) < $this->delta) || ($operand1 $operand2));
                } elseif (
$useLowercaseFirstComparison) {
                    
$result $this->strcmpLowercaseFirst($operand1$operand2) >= 0;
                } else {
                    
$result strcmp($operand1$operand2) >= 0;
                }
                break;
            
//    Less than or equal
            
case '<=':
                if (
is_numeric($operand1) && is_numeric($operand2)) {
                    
$result = ((abs($operand1 $operand2) < $this->delta) || ($operand1 $operand2));
                } elseif (
$useLowercaseFirstComparison) {
                    
$result $this->strcmpLowercaseFirst($operand1$operand2) <= 0;
                } else {
                    
$result strcmp($operand1$operand2) <= 0;
                }
                break;
            
//    Inequality
            
case '<>':
                if (
is_numeric($operand1) && is_numeric($operand2)) {
                    
$result = (abs($operand1 $operand2) > 1E-14);
                } else {
                    
$result strcmp($operand1$operand2) != 0;
                }
                break;
        }

        
//    Log the result details
        
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($result));
        
//    And push the result onto the stack
        
$stack->push('Value',$result);
        return 
true;
    }

    
/**
     * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters
     * @param    string    $str1    First string value for the comparison
     * @param    string    $str2    Second string value for the comparison
     * @return   integer
     */
    
private function strcmpLowercaseFirst($str1$str2)
    {
        
$inversedStr1 PHPExcel_Shared_String::StrCaseReverse($str1);
        
$inversedStr2 PHPExcel_Shared_String::StrCaseReverse($str2);

        return 
strcmp($inversedStr1$inversedStr2);
    }

    private function 
_executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) {
        
//    Validate the two operands
        
if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return FALSE;
        if (!
$this->_validateBinaryOperand($cellID,$operand2,$stack)) return FALSE;

        
//    If either of the operands is a matrix, we need to treat them both as matrices
        //        (converting the other operand to a matrix if need be); then perform the required
        //        matrix operation
        
if ((is_array($operand1)) || (is_array($operand2))) {
            
//    Ensure that both operands are arrays/matrices of the same size
            
self::_checkMatrixOperands($operand1$operand22);

            try {
                
//    Convert operand 1 from a PHP array to a matrix
                
$matrix = new PHPExcel_Shared_JAMA_Matrix($operand1);
                
//    Perform the required operation against the operand 1 matrix, passing in operand 2
                
$matrixResult $matrix->$matrixFunction($operand2);
                
$result $matrixResult->getArray();
            } catch (
PHPExcel_Exception $ex) {
                
$this->_debugLog->writeDebugLog('JAMA Matrix Exception: '$ex->getMessage());
                
$result '#VALUE!';
            }
        } else {
            if ((
PHPExcel_Calculation_Functions::getCompatibilityMode() != PHPExcel_Calculation_Functions::COMPATIBILITY_OPENOFFICE) &&
                ((
is_string($operand1) && !is_numeric($operand1) && strlen($operand1)>0) || 
                 (
is_string($operand2) && !is_numeric($operand2) && strlen($operand2)>0))) {
                
$result PHPExcel_Calculation_Functions::VALUE();
            } else {
                
//    If we're dealing with non-matrix operations, execute the necessary operation
                
switch ($operation) {
                    
//    Addition
                    
case '+':
                        
$result $operand1 $operand2;
                        break;
                    
//    Subtraction
                    
case '-':
                        
$result $operand1 $operand2;
                        break;
                    
//    Multiplication
                    
case '*':
                        
$result $operand1 $operand2;
                        break;
                    
//    Division
                    
case '/':
                        if (
$operand2 == 0) {
                            
//    Trap for Divide by Zero error
                            
$stack->push('Value','#DIV/0!');
                            
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails('#DIV/0!'));
                            return 
FALSE;
                        } else {
                            
$result $operand1 $operand2;
                        }
                        break;
                    
//    Power
                    
case '^':
                        
$result pow($operand1$operand2);
                        break;
                }
            }
        }

        
//    Log the result details
        
$this->_debugLog->writeDebugLog('Evaluation Result is '$this->_showTypeDetails($result));
        
//    And push the result onto the stack
        
$stack->push('Value',$result);
        return 
TRUE;
    }    
//    function _executeNumericBinaryOperation()


    // trigger an error, but nicely, if need be
    
protected function _raiseFormulaError($errorMessage) {
        
$this->formulaError $errorMessage;
        
$this->_cyclicReferenceStack->clear();
        if (!
$this->suppressFormulaErrors) throw new PHPExcel_Calculation_Exception($errorMessage);
        
trigger_error($errorMessageE_USER_ERROR);
    }    
//    function _raiseFormulaError()


    /**
     * Extract range values
     *
     * @param    string                &$pRange    String based range representation
     * @param    PHPExcel_Worksheet    $pSheet        Worksheet
     * @param    boolean                $resetLog    Flag indicating whether calculation log should be reset or not
     * @return  mixed                Array of values in range if range contains more than one element. Otherwise, a single value is returned.
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function extractCellRange(&$pRange 'A1'PHPExcel_Worksheet $pSheet NULL$resetLog TRUE) {
        
// Return value
        
$returnValue = array ();

//        echo 'extractCellRange('.$pRange.')',PHP_EOL;
        
if ($pSheet !== NULL) {
            
$pSheetName $pSheet->getTitle();
//            echo 'Passed sheet name is '.$pSheetName.PHP_EOL;
//            echo 'Range reference is '.$pRange.PHP_EOL;
            
if (strpos ($pRange'!') !== false) {
//                echo '$pRange reference includes sheet reference',PHP_EOL;
                
list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRangetrue);
//                echo 'New sheet name is '.$pSheetName,PHP_EOL;
//                echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
                
$pSheet $this->_workbook->getSheetByName($pSheetName);
            }

            
// Extract range
            
$aReferences PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
            
$pRange $pSheetName.'!'.$pRange;
            if (!isset(
$aReferences[1])) {
                
//    Single cell in range
                
sscanf($aReferences[0],'%[A-Z]%d'$currentCol$currentRow);
                
$cellValue NULL;
                if (
$pSheet->cellExists($aReferences[0])) {
                    
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
                } else {
                    
$returnValue[$currentRow][$currentCol] = NULL;
                }
            } else {
                
// Extract cell data for all cells in the range
                
foreach ($aReferences as $reference) {
                    
// Extract range
                    
sscanf($reference,'%[A-Z]%d'$currentCol$currentRow);
                    
$cellValue NULL;
                    if (
$pSheet->cellExists($reference)) {
                        
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
                    } else {
                        
$returnValue[$currentRow][$currentCol] = NULL;
                    }
                }
            }
        }

        
// Return
        
return $returnValue;
    }    
//    function extractCellRange()


    /**
     * Extract range values
     *
     * @param    string                &$pRange    String based range representation
     * @param    PHPExcel_Worksheet    $pSheet        Worksheet
     * @return  mixed                Array of values in range if range contains more than one element. Otherwise, a single value is returned.
     * @param    boolean                $resetLog    Flag indicating whether calculation log should be reset or not
     * @throws    PHPExcel_Calculation_Exception
     */
    
public function extractNamedRange(&$pRange 'A1'PHPExcel_Worksheet $pSheet NULL$resetLog TRUE) {
        
// Return value
        
$returnValue = array ();

//        echo 'extractNamedRange('.$pRange.')<br />';
        
if ($pSheet !== NULL) {
            
$pSheetName $pSheet->getTitle();
//            echo 'Current sheet name is '.$pSheetName.'<br />';
//            echo 'Range reference is '.$pRange.'<br />';
            
if (strpos ($pRange'!') !== false) {
//                echo '$pRange reference includes sheet reference',PHP_EOL;
                
list($pSheetName,$pRange) = PHPExcel_Worksheet::extractSheetTitle($pRangetrue);
//                echo 'New sheet name is '.$pSheetName,PHP_EOL;
//                echo 'Adjusted Range reference is '.$pRange,PHP_EOL;
                
$pSheet $this->_workbook->getSheetByName($pSheetName);
            }

            
// Named range?
            
$namedRange PHPExcel_NamedRange::resolveRange($pRange$pSheet);
            if (
$namedRange !== NULL) {
                
$pSheet $namedRange->getWorksheet();
//                echo 'Named Range '.$pRange.' (';
                
$pRange $namedRange->getRange();
                
$splitRange PHPExcel_Cell::splitRange($pRange);
                
//    Convert row and column references
                
if (ctype_alpha($splitRange[0][0])) {
                    
$pRange $splitRange[0][0] . '1:' $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow();
                } elseif(
ctype_digit($splitRange[0][0])) {
                    
$pRange 'A' $splitRange[0][0] . ':' $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];
                }
//                echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />';

//                if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
//                    if (!$namedRange->getLocalOnly()) {
//                        $pSheet = $namedRange->getWorksheet();
//                    } else {
//                        return $returnValue;
//                    }
//                }
            
} else {
                return 
PHPExcel_Calculation_Functions::REF();
            }

            
// Extract range
            
$aReferences PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
//            var_dump($aReferences);
            
if (!isset($aReferences[1])) {
                
//    Single cell (or single column or row) in range
                
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
                
$cellValue NULL;
                if (
$pSheet->cellExists($aReferences[0])) {
                    
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
                } else {
                    
$returnValue[$currentRow][$currentCol] = NULL;
                }
            } else {
                
// Extract cell data for all cells in the range
                
foreach ($aReferences as $reference) {
                    
// Extract range
                    
list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
//                    echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />';
                    
$cellValue NULL;
                    if (
$pSheet->cellExists($reference)) {
                        
$returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
                    } else {
                        
$returnValue[$currentRow][$currentCol] = NULL;
                    }
                }
            }
//                print_r($returnValue);
//            echo '<br />';
        
}

        
// Return
        
return $returnValue;
    }    
//    function extractNamedRange()


    /**
     * Is a specific function implemented?
     *
     * @param    string    $pFunction    Function Name
     * @return    boolean
     */
    
public function isImplemented($pFunction '') {
        
$pFunction strtoupper ($pFunction);
        if (isset(
self::$_PHPExcelFunctions[$pFunction])) {
            return (
self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
        } else {
            return 
FALSE;
        }
    }    
//    function isImplemented()


    /**
     * Get a list of all implemented functions as an array of function objects
     *
     * @return    array of PHPExcel_Calculation_Function
     */
    
public function listFunctions() {
        
// Return value
        
$returnValue = array();
        
// Loop functions
        
foreach(self::$_PHPExcelFunctions as $functionName => $function) {
            if (
$function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
                
$returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'],
                                                                                
$functionName,
                                                                                
$function['functionCall']
                                                                               );
            }
        }

        
// Return
        
return $returnValue;
    }    
//    function listFunctions()


    /**
     * Get a list of all Excel function names
     *
     * @return    array
     */
    
public function listAllFunctionNames() {
        return 
array_keys(self::$_PHPExcelFunctions);
    }    
//    function listAllFunctionNames()

    /**
     * Get a list of implemented Excel function names
     *
     * @return    array
     */
    
public function listFunctionNames() {
        
// Return value
        
$returnValue = array();
        
// Loop functions
        
foreach(self::$_PHPExcelFunctions as $functionName => $function) {
            if (
$function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
                
$returnValue[] = $functionName;
            }
        }

        
// Return
        
return $returnValue;
    }    
//    function listFunctionNames()

}    //    class PHPExcel_Calculation