PageRenderTime 74ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 1ms

/framework/includes/tools/phpMyAdmin/libraries/PHPExcel/PHPExcel/Calculation.php

https://bitbucket.org/tripodreporting/development-to-production-webservice
PHP | 3702 lines | 2906 code | 228 blank | 568 comment | 398 complexity | a36d2affa05892c3d795fa3765b86512 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * PHPExcel
  4. *
  5. * Copyright (c) 2006 - 2010 PHPExcel
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * @category PHPExcel
  22. * @package PHPExcel_Calculation
  23. * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  24. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  25. * @version 1.7.4, 2010-08-26
  26. */
  27. /** PHPExcel root directory */
  28. if (!defined('PHPEXCEL_ROOT')) {
  29. /**
  30. * @ignore
  31. */
  32. define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../');
  33. require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  34. PHPExcel_Autoloader::Register();
  35. PHPExcel_Shared_ZipStreamWrapper::register();
  36. // check mbstring.func_overload
  37. if (ini_get('mbstring.func_overload') & 2) {
  38. throw new Exception('Multibyte function overloading in PHP must be disabled for string functions (2).');
  39. }
  40. }
  41. /** Matrix */
  42. require_once PHPEXCEL_ROOT . 'PHPExcel/Shared/JAMA/Matrix.php';
  43. /**
  44. * PHPExcel_Calculation (Singleton)
  45. *
  46. * @category PHPExcel
  47. * @package PHPExcel_Calculation
  48. * @copyright Copyright (c) 2006 - 2010 PHPExcel (http://www.codeplex.com/PHPExcel)
  49. */
  50. class PHPExcel_Calculation {
  51. /** Constants */
  52. /** Regular Expressions */
  53. // Numeric operand
  54. const CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?';
  55. // String operand
  56. const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"';
  57. // Opening bracket
  58. const CALCULATION_REGEXP_OPENBRACE = '\(';
  59. // Function
  60. const CALCULATION_REGEXP_FUNCTION = '@?([A-Z][A-Z0-9\.]*)[\s]*\(';
  61. // Cell reference (cell or range of cells, with or without a sheet reference)
  62. const CALCULATION_REGEXP_CELLREF = '(((\w*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?([a-z]{1,3})\$?(\d+)';
  63. // Named Range of cells
  64. const CALCULATION_REGEXP_NAMEDRANGE = '(((\w*)|(\'.*\')|(\".*\"))!)?([_A-Z][_A-Z0-9]*)';
  65. // Error
  66. const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?';
  67. /** constants */
  68. const RETURN_ARRAY_AS_ERROR = 'error';
  69. const RETURN_ARRAY_AS_VALUE = 'value';
  70. const RETURN_ARRAY_AS_ARRAY = 'array';
  71. private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE;
  72. /**
  73. * Instance of this class
  74. *
  75. * @access private
  76. * @var PHPExcel_Calculation
  77. */
  78. private static $_instance;
  79. /**
  80. * Calculation cache
  81. *
  82. * @access private
  83. * @var array
  84. */
  85. private static $_calculationCache = array ();
  86. /**
  87. * Calculation cache enabled
  88. *
  89. * @access private
  90. * @var boolean
  91. */
  92. private static $_calculationCacheEnabled = true;
  93. /**
  94. * Calculation cache expiration time
  95. *
  96. * @access private
  97. * @var float
  98. */
  99. private static $_calculationCacheExpirationTime = 15;
  100. /**
  101. * List of operators that can be used within formulae
  102. *
  103. * @access private
  104. * @var array
  105. */
  106. private static $_operators = array('+', '-', '*', '/', '^', '&', '%', '~', '>', '<', '=', '>=', '<=', '<>', '|', ':');
  107. /**
  108. * List of binary operators (those that expect two operands)
  109. *
  110. * @access private
  111. * @var array
  112. */
  113. private static $_binaryOperators = array('+', '-', '*', '/', '^', '&', '>', '<', '=', '>=', '<=', '<>', '|', ':');
  114. /**
  115. * Flag to determine how formula errors should be handled
  116. * If true, then a user error will be triggered
  117. * If false, then an exception will be thrown
  118. *
  119. * @access public
  120. * @var boolean
  121. *
  122. */
  123. public $suppressFormulaErrors = false;
  124. /**
  125. * Error message for any error that was raised/thrown by the calculation engine
  126. *
  127. * @access public
  128. * @var string
  129. *
  130. */
  131. public $formulaError = null;
  132. /**
  133. * Flag to determine whether a debug log should be generated by the calculation engine
  134. * If true, then a debug log will be generated
  135. * If false, then a debug log will not be generated
  136. *
  137. * @access public
  138. * @var boolean
  139. *
  140. */
  141. public $writeDebugLog = false;
  142. /**
  143. * An array of the nested cell references accessed by the calculation engine, used for the debug log
  144. *
  145. * @access private
  146. * @var array of string
  147. *
  148. */
  149. private $debugLogStack = array();
  150. /**
  151. * The debug log generated by the calculation engine
  152. *
  153. * @access public
  154. * @var array of string
  155. *
  156. */
  157. public $debugLog = array();
  158. private $_cyclicFormulaCount = 0;
  159. private $_cyclicFormulaCell = '';
  160. public $cyclicFormulaCount = 0;
  161. private static $_localeLanguage = 'en_us'; // US English (default locale)
  162. private static $_validLocaleLanguages = array( 'en' // English (default language)
  163. );
  164. private static $_localeArgumentSeparator = ',';
  165. private static $_localeFunctions = array();
  166. private static $_localeBoolean = array( 'TRUE' => 'TRUE',
  167. 'FALSE' => 'FALSE',
  168. 'NULL' => 'NULL'
  169. );
  170. // Constant conversion from text name/value to actual (datatyped) value
  171. private static $_ExcelConstants = array('TRUE' => True,
  172. 'FALSE' => False,
  173. 'NULL' => Null
  174. );
  175. // PHPExcel functions
  176. private static $_PHPExcelFunctions = array( // PHPExcel functions
  177. 'ABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  178. 'functionCall' => 'abs',
  179. 'argumentCount' => '1'
  180. ),
  181. 'ACCRINT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  182. 'functionCall' => 'PHPExcel_Calculation_Functions::ACCRINT',
  183. 'argumentCount' => '4-7'
  184. ),
  185. 'ACCRINTM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  186. 'functionCall' => 'PHPExcel_Calculation_Functions::ACCRINTM',
  187. 'argumentCount' => '3-5'
  188. ),
  189. 'ACOS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  190. 'functionCall' => 'acos',
  191. 'argumentCount' => '1'
  192. ),
  193. 'ACOSH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  194. 'functionCall' => 'acosh',
  195. 'argumentCount' => '1'
  196. ),
  197. 'ADDRESS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  198. 'functionCall' => 'PHPExcel_Calculation_Functions::CELL_ADDRESS',
  199. 'argumentCount' => '2-5'
  200. ),
  201. 'AMORDEGRC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  202. 'functionCall' => 'PHPExcel_Calculation_Functions::AMORDEGRC',
  203. 'argumentCount' => '6,7'
  204. ),
  205. 'AMORLINC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  206. 'functionCall' => 'PHPExcel_Calculation_Functions::AMORLINC',
  207. 'argumentCount' => '6,7'
  208. ),
  209. 'AND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  210. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGICAL_AND',
  211. 'argumentCount' => '1+'
  212. ),
  213. 'AREAS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  214. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  215. 'argumentCount' => '1'
  216. ),
  217. 'ASC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  218. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  219. 'argumentCount' => '1'
  220. ),
  221. 'ASIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  222. 'functionCall' => 'asin',
  223. 'argumentCount' => '1'
  224. ),
  225. 'ASINH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  226. 'functionCall' => 'asinh',
  227. 'argumentCount' => '1'
  228. ),
  229. 'ATAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  230. 'functionCall' => 'atan',
  231. 'argumentCount' => '1'
  232. ),
  233. 'ATAN2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  234. 'functionCall' => 'PHPExcel_Calculation_Functions::REVERSE_ATAN2',
  235. 'argumentCount' => '2'
  236. ),
  237. 'ATANH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  238. 'functionCall' => 'atanh',
  239. 'argumentCount' => '1'
  240. ),
  241. 'AVEDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  242. 'functionCall' => 'PHPExcel_Calculation_Functions::AVEDEV',
  243. 'argumentCount' => '1+'
  244. ),
  245. 'AVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  246. 'functionCall' => 'PHPExcel_Calculation_Functions::AVERAGE',
  247. 'argumentCount' => '1+'
  248. ),
  249. 'AVERAGEA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  250. 'functionCall' => 'PHPExcel_Calculation_Functions::AVERAGEA',
  251. 'argumentCount' => '1+'
  252. ),
  253. 'AVERAGEIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  254. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  255. 'argumentCount' => '2,3'
  256. ),
  257. 'AVERAGEIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  258. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  259. 'argumentCount' => '3+'
  260. ),
  261. 'BAHTTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  262. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  263. 'argumentCount' => '1'
  264. ),
  265. 'BESSELI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  266. 'functionCall' => 'PHPExcel_Calculation_Functions::BESSELI',
  267. 'argumentCount' => '2'
  268. ),
  269. 'BESSELJ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  270. 'functionCall' => 'PHPExcel_Calculation_Functions::BESSELJ',
  271. 'argumentCount' => '2'
  272. ),
  273. 'BESSELK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  274. 'functionCall' => 'PHPExcel_Calculation_Functions::BESSELK',
  275. 'argumentCount' => '2'
  276. ),
  277. 'BESSELY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  278. 'functionCall' => 'PHPExcel_Calculation_Functions::BESSELY',
  279. 'argumentCount' => '2'
  280. ),
  281. 'BETADIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  282. 'functionCall' => 'PHPExcel_Calculation_Functions::BETADIST',
  283. 'argumentCount' => '3-5'
  284. ),
  285. 'BETAINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  286. 'functionCall' => 'PHPExcel_Calculation_Functions::BETAINV',
  287. 'argumentCount' => '3-5'
  288. ),
  289. 'BIN2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  290. 'functionCall' => 'PHPExcel_Calculation_Functions::BINTODEC',
  291. 'argumentCount' => '1'
  292. ),
  293. 'BIN2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  294. 'functionCall' => 'PHPExcel_Calculation_Functions::BINTOHEX',
  295. 'argumentCount' => '1,2'
  296. ),
  297. 'BIN2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  298. 'functionCall' => 'PHPExcel_Calculation_Functions::BINTOOCT',
  299. 'argumentCount' => '1,2'
  300. ),
  301. 'BINOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  302. 'functionCall' => 'PHPExcel_Calculation_Functions::BINOMDIST',
  303. 'argumentCount' => '4'
  304. ),
  305. 'CEILING' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  306. 'functionCall' => 'PHPExcel_Calculation_Functions::CEILING',
  307. 'argumentCount' => '2'
  308. ),
  309. 'CELL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  310. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  311. 'argumentCount' => '1,2'
  312. ),
  313. 'CHAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  314. 'functionCall' => 'PHPExcel_Calculation_Functions::CHARACTER',
  315. 'argumentCount' => '1'
  316. ),
  317. 'CHIDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  318. 'functionCall' => 'PHPExcel_Calculation_Functions::CHIDIST',
  319. 'argumentCount' => '2'
  320. ),
  321. 'CHIINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  322. 'functionCall' => 'PHPExcel_Calculation_Functions::CHIINV',
  323. 'argumentCount' => '2'
  324. ),
  325. 'CHITEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  326. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  327. 'argumentCount' => '2'
  328. ),
  329. 'CHOOSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  330. 'functionCall' => 'PHPExcel_Calculation_Functions::CHOOSE',
  331. 'argumentCount' => '2+'
  332. ),
  333. 'CLEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  334. 'functionCall' => 'PHPExcel_Calculation_Functions::TRIMNONPRINTABLE',
  335. 'argumentCount' => '1'
  336. ),
  337. 'CODE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  338. 'functionCall' => 'PHPExcel_Calculation_Functions::ASCIICODE',
  339. 'argumentCount' => '1'
  340. ),
  341. 'COLUMN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  342. 'functionCall' => 'PHPExcel_Calculation_Functions::COLUMN',
  343. 'argumentCount' => '-1',
  344. 'passByReference' => array(true)
  345. ),
  346. 'COLUMNS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  347. 'functionCall' => 'PHPExcel_Calculation_Functions::COLUMNS',
  348. 'argumentCount' => '1'
  349. ),
  350. 'COMBIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  351. 'functionCall' => 'PHPExcel_Calculation_Functions::COMBIN',
  352. 'argumentCount' => '2'
  353. ),
  354. 'COMPLEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  355. 'functionCall' => 'PHPExcel_Calculation_Functions::COMPLEX',
  356. 'argumentCount' => '2,3'
  357. ),
  358. 'CONCATENATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  359. 'functionCall' => 'PHPExcel_Calculation_Functions::CONCATENATE',
  360. 'argumentCount' => '1+'
  361. ),
  362. 'CONFIDENCE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  363. 'functionCall' => 'PHPExcel_Calculation_Functions::CONFIDENCE',
  364. 'argumentCount' => '3'
  365. ),
  366. 'CONVERT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  367. 'functionCall' => 'PHPExcel_Calculation_Functions::CONVERTUOM',
  368. 'argumentCount' => '3'
  369. ),
  370. 'CORREL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  371. 'functionCall' => 'PHPExcel_Calculation_Functions::CORREL',
  372. 'argumentCount' => '2'
  373. ),
  374. 'COS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  375. 'functionCall' => 'cos',
  376. 'argumentCount' => '1'
  377. ),
  378. 'COSH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  379. 'functionCall' => 'cosh',
  380. 'argumentCount' => '1'
  381. ),
  382. 'COUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  383. 'functionCall' => 'PHPExcel_Calculation_Functions::COUNT',
  384. 'argumentCount' => '1+'
  385. ),
  386. 'COUNTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  387. 'functionCall' => 'PHPExcel_Calculation_Functions::COUNTA',
  388. 'argumentCount' => '1+'
  389. ),
  390. 'COUNTBLANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  391. 'functionCall' => 'PHPExcel_Calculation_Functions::COUNTBLANK',
  392. 'argumentCount' => '1'
  393. ),
  394. 'COUNTIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  395. 'functionCall' => 'PHPExcel_Calculation_Functions::COUNTIF',
  396. 'argumentCount' => '2'
  397. ),
  398. 'COUNTIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  399. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  400. 'argumentCount' => '2'
  401. ),
  402. 'COUPDAYBS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  403. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYBS',
  404. 'argumentCount' => '3,4'
  405. ),
  406. 'COUPDAYS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  407. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYS',
  408. 'argumentCount' => '3,4'
  409. ),
  410. 'COUPDAYSNC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  411. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPDAYSNC',
  412. 'argumentCount' => '3,4'
  413. ),
  414. 'COUPNCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  415. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPNCD',
  416. 'argumentCount' => '3,4'
  417. ),
  418. 'COUPNUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  419. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPNUM',
  420. 'argumentCount' => '3,4'
  421. ),
  422. 'COUPPCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  423. 'functionCall' => 'PHPExcel_Calculation_Functions::COUPPCD',
  424. 'argumentCount' => '3,4'
  425. ),
  426. 'COVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  427. 'functionCall' => 'PHPExcel_Calculation_Functions::COVAR',
  428. 'argumentCount' => '2'
  429. ),
  430. 'CRITBINOM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  431. 'functionCall' => 'PHPExcel_Calculation_Functions::CRITBINOM',
  432. 'argumentCount' => '3'
  433. ),
  434. 'CUBEKPIMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  435. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  436. 'argumentCount' => '?'
  437. ),
  438. 'CUBEMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  439. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  440. 'argumentCount' => '?'
  441. ),
  442. 'CUBEMEMBERPROPERTY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  443. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  444. 'argumentCount' => '?'
  445. ),
  446. 'CUBERANKEDMEMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  447. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  448. 'argumentCount' => '?'
  449. ),
  450. 'CUBESET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  451. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  452. 'argumentCount' => '?'
  453. ),
  454. 'CUBESETCOUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  455. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  456. 'argumentCount' => '?'
  457. ),
  458. 'CUBEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_CUBE,
  459. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  460. 'argumentCount' => '?'
  461. ),
  462. 'CUMIPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  463. 'functionCall' => 'PHPExcel_Calculation_Functions::CUMIPMT',
  464. 'argumentCount' => '6'
  465. ),
  466. 'CUMPRINC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  467. 'functionCall' => 'PHPExcel_Calculation_Functions::CUMPRINC',
  468. 'argumentCount' => '6'
  469. ),
  470. 'DATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  471. 'functionCall' => 'PHPExcel_Calculation_Functions::DATE',
  472. 'argumentCount' => '3'
  473. ),
  474. 'DATEDIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  475. 'functionCall' => 'PHPExcel_Calculation_Functions::DATEDIF',
  476. 'argumentCount' => '2,3'
  477. ),
  478. 'DATEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  479. 'functionCall' => 'PHPExcel_Calculation_Functions::DATEVALUE',
  480. 'argumentCount' => '1'
  481. ),
  482. 'DAVERAGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  483. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  484. 'argumentCount' => '3'
  485. ),
  486. 'DAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  487. 'functionCall' => 'PHPExcel_Calculation_Functions::DAYOFMONTH',
  488. 'argumentCount' => '1'
  489. ),
  490. 'DAYS360' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  491. 'functionCall' => 'PHPExcel_Calculation_Functions::DAYS360',
  492. 'argumentCount' => '2,3'
  493. ),
  494. 'DB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  495. 'functionCall' => 'PHPExcel_Calculation_Functions::DB',
  496. 'argumentCount' => '4,5'
  497. ),
  498. 'DCOUNT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  499. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  500. 'argumentCount' => '3'
  501. ),
  502. 'DCOUNTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  503. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  504. 'argumentCount' => '3'
  505. ),
  506. 'DDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  507. 'functionCall' => 'PHPExcel_Calculation_Functions::DDB',
  508. 'argumentCount' => '4,5'
  509. ),
  510. 'DEC2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  511. 'functionCall' => 'PHPExcel_Calculation_Functions::DECTOBIN',
  512. 'argumentCount' => '1,2'
  513. ),
  514. 'DEC2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  515. 'functionCall' => 'PHPExcel_Calculation_Functions::DECTOHEX',
  516. 'argumentCount' => '1,2'
  517. ),
  518. 'DEC2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  519. 'functionCall' => 'PHPExcel_Calculation_Functions::DECTOOCT',
  520. 'argumentCount' => '1,2'
  521. ),
  522. 'DEGREES' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  523. 'functionCall' => 'rad2deg',
  524. 'argumentCount' => '1'
  525. ),
  526. 'DELTA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  527. 'functionCall' => 'PHPExcel_Calculation_Functions::DELTA',
  528. 'argumentCount' => '1,2'
  529. ),
  530. 'DEVSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  531. 'functionCall' => 'PHPExcel_Calculation_Functions::DEVSQ',
  532. 'argumentCount' => '1+'
  533. ),
  534. 'DGET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  535. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  536. 'argumentCount' => '3'
  537. ),
  538. 'DISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  539. 'functionCall' => 'PHPExcel_Calculation_Functions::DISC',
  540. 'argumentCount' => '4,5'
  541. ),
  542. 'DMAX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  543. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  544. 'argumentCount' => '3'
  545. ),
  546. 'DMIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  547. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  548. 'argumentCount' => '3'
  549. ),
  550. 'DOLLAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  551. 'functionCall' => 'PHPExcel_Calculation_Functions::DOLLAR',
  552. 'argumentCount' => '1,2'
  553. ),
  554. 'DOLLARDE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  555. 'functionCall' => 'PHPExcel_Calculation_Functions::DOLLARDE',
  556. 'argumentCount' => '2'
  557. ),
  558. 'DOLLARFR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  559. 'functionCall' => 'PHPExcel_Calculation_Functions::DOLLARFR',
  560. 'argumentCount' => '2'
  561. ),
  562. 'DPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  563. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  564. 'argumentCount' => '3'
  565. ),
  566. 'DSTDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  567. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  568. 'argumentCount' => '3'
  569. ),
  570. 'DSTDEVP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  571. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  572. 'argumentCount' => '3'
  573. ),
  574. 'DSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  575. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  576. 'argumentCount' => '3'
  577. ),
  578. 'DURATION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  579. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  580. 'argumentCount' => '5,6'
  581. ),
  582. 'DVAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  583. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  584. 'argumentCount' => '3'
  585. ),
  586. 'DVARP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
  587. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  588. 'argumentCount' => '3'
  589. ),
  590. 'EDATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  591. 'functionCall' => 'PHPExcel_Calculation_Functions::EDATE',
  592. 'argumentCount' => '2'
  593. ),
  594. 'EFFECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  595. 'functionCall' => 'PHPExcel_Calculation_Functions::EFFECT',
  596. 'argumentCount' => '2'
  597. ),
  598. 'EOMONTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  599. 'functionCall' => 'PHPExcel_Calculation_Functions::EOMONTH',
  600. 'argumentCount' => '2'
  601. ),
  602. 'ERF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  603. 'functionCall' => 'PHPExcel_Calculation_Functions::ERF',
  604. 'argumentCount' => '1,2'
  605. ),
  606. 'ERFC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  607. 'functionCall' => 'PHPExcel_Calculation_Functions::ERFC',
  608. 'argumentCount' => '1'
  609. ),
  610. 'ERROR.TYPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  611. 'functionCall' => 'PHPExcel_Calculation_Functions::ERROR_TYPE',
  612. 'argumentCount' => '1'
  613. ),
  614. 'EVEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  615. 'functionCall' => 'PHPExcel_Calculation_Functions::EVEN',
  616. 'argumentCount' => '1'
  617. ),
  618. 'EXACT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  619. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  620. 'argumentCount' => '2'
  621. ),
  622. 'EXP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  623. 'functionCall' => 'exp',
  624. 'argumentCount' => '1'
  625. ),
  626. 'EXPONDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  627. 'functionCall' => 'PHPExcel_Calculation_Functions::EXPONDIST',
  628. 'argumentCount' => '3'
  629. ),
  630. 'FACT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  631. 'functionCall' => 'PHPExcel_Calculation_Functions::FACT',
  632. 'argumentCount' => '1'
  633. ),
  634. 'FACTDOUBLE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  635. 'functionCall' => 'PHPExcel_Calculation_Functions::FACTDOUBLE',
  636. 'argumentCount' => '1'
  637. ),
  638. 'FALSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  639. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGICAL_FALSE',
  640. 'argumentCount' => '0'
  641. ),
  642. 'FDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  643. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  644. 'argumentCount' => '3'
  645. ),
  646. 'FIND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  647. 'functionCall' => 'PHPExcel_Calculation_Functions::SEARCHSENSITIVE',
  648. 'argumentCount' => '2,3'
  649. ),
  650. 'FINDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  651. 'functionCall' => 'PHPExcel_Calculation_Functions::SEARCHSENSITIVE',
  652. 'argumentCount' => '2,3'
  653. ),
  654. 'FINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  655. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  656. 'argumentCount' => '3'
  657. ),
  658. 'FISHER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  659. 'functionCall' => 'PHPExcel_Calculation_Functions::FISHER',
  660. 'argumentCount' => '1'
  661. ),
  662. 'FISHERINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  663. 'functionCall' => 'PHPExcel_Calculation_Functions::FISHERINV',
  664. 'argumentCount' => '1'
  665. ),
  666. 'FIXED' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  667. 'functionCall' => 'PHPExcel_Calculation_Functions::FIXEDFORMAT',
  668. 'argumentCount' => '1-3'
  669. ),
  670. 'FLOOR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  671. 'functionCall' => 'PHPExcel_Calculation_Functions::FLOOR',
  672. 'argumentCount' => '2'
  673. ),
  674. 'FORECAST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  675. 'functionCall' => 'PHPExcel_Calculation_Functions::FORECAST',
  676. 'argumentCount' => '3'
  677. ),
  678. 'FREQUENCY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  679. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  680. 'argumentCount' => '2'
  681. ),
  682. 'FTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  683. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  684. 'argumentCount' => '2'
  685. ),
  686. 'FV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  687. 'functionCall' => 'PHPExcel_Calculation_Functions::FV',
  688. 'argumentCount' => '3-5'
  689. ),
  690. 'FVSCHEDULE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  691. 'functionCall' => 'PHPExcel_Calculation_Functions::FVSCHEDULE',
  692. 'argumentCount' => '2'
  693. ),
  694. 'GAMMADIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  695. 'functionCall' => 'PHPExcel_Calculation_Functions::GAMMADIST',
  696. 'argumentCount' => '4'
  697. ),
  698. 'GAMMAINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  699. 'functionCall' => 'PHPExcel_Calculation_Functions::GAMMAINV',
  700. 'argumentCount' => '3'
  701. ),
  702. 'GAMMALN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  703. 'functionCall' => 'PHPExcel_Calculation_Functions::GAMMALN',
  704. 'argumentCount' => '1'
  705. ),
  706. 'GCD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  707. 'functionCall' => 'PHPExcel_Calculation_Functions::GCD',
  708. 'argumentCount' => '1+'
  709. ),
  710. 'GEOMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  711. 'functionCall' => 'PHPExcel_Calculation_Functions::GEOMEAN',
  712. 'argumentCount' => '1+'
  713. ),
  714. 'GESTEP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  715. 'functionCall' => 'PHPExcel_Calculation_Functions::GESTEP',
  716. 'argumentCount' => '1,2'
  717. ),
  718. 'GETPIVOTDATA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  719. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  720. 'argumentCount' => '2+'
  721. ),
  722. 'GROWTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  723. 'functionCall' => 'PHPExcel_Calculation_Functions::GROWTH',
  724. 'argumentCount' => '1-4'
  725. ),
  726. 'HARMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  727. 'functionCall' => 'PHPExcel_Calculation_Functions::HARMEAN',
  728. 'argumentCount' => '1+'
  729. ),
  730. 'HEX2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  731. 'functionCall' => 'PHPExcel_Calculation_Functions::HEXTOBIN',
  732. 'argumentCount' => '1,2'
  733. ),
  734. 'HEX2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  735. 'functionCall' => 'PHPExcel_Calculation_Functions::HEXTODEC',
  736. 'argumentCount' => '1'
  737. ),
  738. 'HEX2OCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  739. 'functionCall' => 'PHPExcel_Calculation_Functions::HEXTOOCT',
  740. 'argumentCount' => '1,2'
  741. ),
  742. 'HLOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  743. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  744. 'argumentCount' => '3,4'
  745. ),
  746. 'HOUR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  747. 'functionCall' => 'PHPExcel_Calculation_Functions::HOUROFDAY',
  748. 'argumentCount' => '1'
  749. ),
  750. 'HYPERLINK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  751. 'functionCall' => 'PHPExcel_Calculation_Functions::HYPERLINK',
  752. 'argumentCount' => '1,2',
  753. 'passCellReference'=> true
  754. ),
  755. 'HYPGEOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  756. 'functionCall' => 'PHPExcel_Calculation_Functions::HYPGEOMDIST',
  757. 'argumentCount' => '4'
  758. ),
  759. 'IF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  760. 'functionCall' => 'PHPExcel_Calculation_Functions::STATEMENT_IF',
  761. 'argumentCount' => '1-3'
  762. ),
  763. 'IFERROR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  764. 'functionCall' => 'PHPExcel_Calculation_Functions::STATEMENT_IFERROR',
  765. 'argumentCount' => '2'
  766. ),
  767. 'IMABS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  768. 'functionCall' => 'PHPExcel_Calculation_Functions::IMABS',
  769. 'argumentCount' => '1'
  770. ),
  771. 'IMAGINARY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  772. 'functionCall' => 'PHPExcel_Calculation_Functions::IMAGINARY',
  773. 'argumentCount' => '1'
  774. ),
  775. 'IMARGUMENT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  776. 'functionCall' => 'PHPExcel_Calculation_Functions::IMARGUMENT',
  777. 'argumentCount' => '1'
  778. ),
  779. 'IMCONJUGATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  780. 'functionCall' => 'PHPExcel_Calculation_Functions::IMCONJUGATE',
  781. 'argumentCount' => '1'
  782. ),
  783. 'IMCOS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  784. 'functionCall' => 'PHPExcel_Calculation_Functions::IMCOS',
  785. 'argumentCount' => '1'
  786. ),
  787. 'IMDIV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  788. 'functionCall' => 'PHPExcel_Calculation_Functions::IMDIV',
  789. 'argumentCount' => '2'
  790. ),
  791. 'IMEXP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  792. 'functionCall' => 'PHPExcel_Calculation_Functions::IMEXP',
  793. 'argumentCount' => '1'
  794. ),
  795. 'IMLN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  796. 'functionCall' => 'PHPExcel_Calculation_Functions::IMLN',
  797. 'argumentCount' => '1'
  798. ),
  799. 'IMLOG10' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  800. 'functionCall' => 'PHPExcel_Calculation_Functions::IMLOG10',
  801. 'argumentCount' => '1'
  802. ),
  803. 'IMLOG2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  804. 'functionCall' => 'PHPExcel_Calculation_Functions::IMLOG2',
  805. 'argumentCount' => '1'
  806. ),
  807. 'IMPOWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  808. 'functionCall' => 'PHPExcel_Calculation_Functions::IMPOWER',
  809. 'argumentCount' => '2'
  810. ),
  811. 'IMPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  812. 'functionCall' => 'PHPExcel_Calculation_Functions::IMPRODUCT',
  813. 'argumentCount' => '1+'
  814. ),
  815. 'IMREAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  816. 'functionCall' => 'PHPExcel_Calculation_Functions::IMREAL',
  817. 'argumentCount' => '1'
  818. ),
  819. 'IMSIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  820. 'functionCall' => 'PHPExcel_Calculation_Functions::IMSIN',
  821. 'argumentCount' => '1'
  822. ),
  823. 'IMSQRT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  824. 'functionCall' => 'PHPExcel_Calculation_Functions::IMSQRT',
  825. 'argumentCount' => '1'
  826. ),
  827. 'IMSUB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  828. 'functionCall' => 'PHPExcel_Calculation_Functions::IMSUB',
  829. 'argumentCount' => '2'
  830. ),
  831. 'IMSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  832. 'functionCall' => 'PHPExcel_Calculation_Functions::IMSUM',
  833. 'argumentCount' => '1+'
  834. ),
  835. 'INDEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  836. 'functionCall' => 'PHPExcel_Calculation_Functions::INDEX',
  837. 'argumentCount' => '1-4'
  838. ),
  839. 'INDIRECT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  840. 'functionCall' => 'PHPExcel_Calculation_Functions::INDIRECT',
  841. 'argumentCount' => '1,2',
  842. 'passCellReference'=> true
  843. ),
  844. 'INFO' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  845. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  846. 'argumentCount' => '1'
  847. ),
  848. 'INT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  849. 'functionCall' => 'PHPExcel_Calculation_Functions::INTVALUE',
  850. 'argumentCount' => '1'
  851. ),
  852. 'INTERCEPT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  853. 'functionCall' => 'PHPExcel_Calculation_Functions::INTERCEPT',
  854. 'argumentCount' => '2'
  855. ),
  856. 'INTRATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  857. 'functionCall' => 'PHPExcel_Calculation_Functions::INTRATE',
  858. 'argumentCount' => '4,5'
  859. ),
  860. 'IPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  861. 'functionCall' => 'PHPExcel_Calculation_Functions::IPMT',
  862. 'argumentCount' => '4-6'
  863. ),
  864. 'IRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  865. 'functionCall' => 'PHPExcel_Calculation_Functions::IRR',
  866. 'argumentCount' => '1,2'
  867. ),
  868. 'ISBLANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  869. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_BLANK',
  870. 'argumentCount' => '1'
  871. ),
  872. 'ISERR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  873. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERR',
  874. 'argumentCount' => '1'
  875. ),
  876. 'ISERROR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  877. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ERROR',
  878. 'argumentCount' => '1'
  879. ),
  880. 'ISEVEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  881. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_EVEN',
  882. 'argumentCount' => '1'
  883. ),
  884. 'ISLOGICAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  885. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_LOGICAL',
  886. 'argumentCount' => '1'
  887. ),
  888. 'ISNA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  889. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NA',
  890. 'argumentCount' => '1'
  891. ),
  892. 'ISNONTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  893. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NONTEXT',
  894. 'argumentCount' => '1'
  895. ),
  896. 'ISNUMBER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  897. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_NUMBER',
  898. 'argumentCount' => '1'
  899. ),
  900. 'ISODD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  901. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_ODD',
  902. 'argumentCount' => '1'
  903. ),
  904. 'ISPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  905. 'functionCall' => 'PHPExcel_Calculation_Functions::ISPMT',
  906. 'argumentCount' => '4'
  907. ),
  908. 'ISREF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  909. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  910. 'argumentCount' => '1'
  911. ),
  912. 'ISTEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  913. 'functionCall' => 'PHPExcel_Calculation_Functions::IS_TEXT',
  914. 'argumentCount' => '1'
  915. ),
  916. 'JIS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  917. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  918. 'argumentCount' => '1'
  919. ),
  920. 'KURT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  921. 'functionCall' => 'PHPExcel_Calculation_Functions::KURT',
  922. 'argumentCount' => '1+'
  923. ),
  924. 'LARGE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  925. 'functionCall' => 'PHPExcel_Calculation_Functions::LARGE',
  926. 'argumentCount' => '2'
  927. ),
  928. 'LCM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  929. 'functionCall' => 'PHPExcel_Calculation_Functions::LCM',
  930. 'argumentCount' => '1+'
  931. ),
  932. 'LEFT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  933. 'functionCall' => 'PHPExcel_Calculation_Functions::LEFT',
  934. 'argumentCount' => '1,2'
  935. ),
  936. 'LEFTB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  937. 'functionCall' => 'PHPExcel_Calculation_Functions::LEFT',
  938. 'argumentCount' => '1,2'
  939. ),
  940. 'LEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  941. 'functionCall' => 'PHPExcel_Calculation_Functions::STRINGLENGTH',
  942. 'argumentCount' => '1'
  943. ),
  944. 'LENB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  945. 'functionCall' => 'PHPExcel_Calculation_Functions::STRINGLENGTH',
  946. 'argumentCount' => '1'
  947. ),
  948. 'LINEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  949. 'functionCall' => 'PHPExcel_Calculation_Functions::LINEST',
  950. 'argumentCount' => '1-4'
  951. ),
  952. 'LN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  953. 'functionCall' => 'log',
  954. 'argumentCount' => '1'
  955. ),
  956. 'LOG' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  957. 'functionCall' => 'PHPExcel_Calculation_Functions::LOG_BASE',
  958. 'argumentCount' => '1,2'
  959. ),
  960. 'LOG10' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  961. 'functionCall' => 'log10',
  962. 'argumentCount' => '1'
  963. ),
  964. 'LOGEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  965. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGEST',
  966. 'argumentCount' => '1-4'
  967. ),
  968. 'LOGINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  969. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGINV',
  970. 'argumentCount' => '3'
  971. ),
  972. 'LOGNORMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  973. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGNORMDIST',
  974. 'argumentCount' => '3'
  975. ),
  976. 'LOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  977. 'functionCall' => 'PHPExcel_Calculation_Functions::LOOKUP',
  978. 'argumentCount' => '2,3'
  979. ),
  980. 'LOWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  981. 'functionCall' => 'PHPExcel_Calculation_Functions::LOWERCASE',
  982. 'argumentCount' => '1'
  983. ),
  984. 'MATCH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  985. 'functionCall' => 'PHPExcel_Calculation_Functions::MATCH',
  986. 'argumentCount' => '2,3'
  987. ),
  988. 'MAX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  989. 'functionCall' => 'PHPExcel_Calculation_Functions::MAX',
  990. 'argumentCount' => '1+'
  991. ),
  992. 'MAXA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  993. 'functionCall' => 'PHPExcel_Calculation_Functions::MAXA',
  994. 'argumentCount' => '1+'
  995. ),
  996. 'MAXIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  997. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  998. 'argumentCount' => '2+'
  999. ),
  1000. 'MDETERM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1001. 'functionCall' => 'PHPExcel_Calculation_Functions::MDETERM',
  1002. 'argumentCount' => '1'
  1003. ),
  1004. 'MDURATION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1005. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1006. 'argumentCount' => '5,6'
  1007. ),
  1008. 'MEDIAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1009. 'functionCall' => 'PHPExcel_Calculation_Functions::MEDIAN',
  1010. 'argumentCount' => '1+'
  1011. ),
  1012. 'MEDIANIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1013. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1014. 'argumentCount' => '2+'
  1015. ),
  1016. 'MID' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1017. 'functionCall' => 'PHPExcel_Calculation_Functions::MID',
  1018. 'argumentCount' => '3'
  1019. ),
  1020. 'MIDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1021. 'functionCall' => 'PHPExcel_Calculation_Functions::MID',
  1022. 'argumentCount' => '3'
  1023. ),
  1024. 'MIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1025. 'functionCall' => 'PHPExcel_Calculation_Functions::MIN',
  1026. 'argumentCount' => '1+'
  1027. ),
  1028. 'MINA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1029. 'functionCall' => 'PHPExcel_Calculation_Functions::MINA',
  1030. 'argumentCount' => '1+'
  1031. ),
  1032. 'MINIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1033. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1034. 'argumentCount' => '2+'
  1035. ),
  1036. 'MINUTE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1037. 'functionCall' => 'PHPExcel_Calculation_Functions::MINUTEOFHOUR',
  1038. 'argumentCount' => '1'
  1039. ),
  1040. 'MINVERSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1041. 'functionCall' => 'PHPExcel_Calculation_Functions::MINVERSE',
  1042. 'argumentCount' => '1'
  1043. ),
  1044. 'MIRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1045. 'functionCall' => 'PHPExcel_Calculation_Functions::MIRR',
  1046. 'argumentCount' => '3'
  1047. ),
  1048. 'MMULT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1049. 'functionCall' => 'PHPExcel_Calculation_Functions::MMULT',
  1050. 'argumentCount' => '2'
  1051. ),
  1052. 'MOD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1053. 'functionCall' => 'PHPExcel_Calculation_Functions::MOD',
  1054. 'argumentCount' => '2'
  1055. ),
  1056. 'MODE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1057. 'functionCall' => 'PHPExcel_Calculation_Functions::MODE',
  1058. 'argumentCount' => '1+'
  1059. ),
  1060. 'MONTH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1061. 'functionCall' => 'PHPExcel_Calculation_Functions::MONTHOFYEAR',
  1062. 'argumentCount' => '1'
  1063. ),
  1064. 'MROUND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1065. 'functionCall' => 'PHPExcel_Calculation_Functions::MROUND',
  1066. 'argumentCount' => '2'
  1067. ),
  1068. 'MULTINOMIAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1069. 'functionCall' => 'PHPExcel_Calculation_Functions::MULTINOMIAL',
  1070. 'argumentCount' => '1+'
  1071. ),
  1072. 'N' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  1073. 'functionCall' => 'PHPExcel_Calculation_Functions::N',
  1074. 'argumentCount' => '1'
  1075. ),
  1076. 'NA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  1077. 'functionCall' => 'PHPExcel_Calculation_Functions::NA',
  1078. 'argumentCount' => '0'
  1079. ),
  1080. 'NEGBINOMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1081. 'functionCall' => 'PHPExcel_Calculation_Functions::NEGBINOMDIST',
  1082. 'argumentCount' => '3'
  1083. ),
  1084. 'NETWORKDAYS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1085. 'functionCall' => 'PHPExcel_Calculation_Functions::NETWORKDAYS',
  1086. 'argumentCount' => '2+'
  1087. ),
  1088. 'NOMINAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1089. 'functionCall' => 'PHPExcel_Calculation_Functions::NOMINAL',
  1090. 'argumentCount' => '2'
  1091. ),
  1092. 'NORMDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1093. 'functionCall' => 'PHPExcel_Calculation_Functions::NORMDIST',
  1094. 'argumentCount' => '4'
  1095. ),
  1096. 'NORMINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1097. 'functionCall' => 'PHPExcel_Calculation_Functions::NORMINV',
  1098. 'argumentCount' => '3'
  1099. ),
  1100. 'NORMSDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1101. 'functionCall' => 'PHPExcel_Calculation_Functions::NORMSDIST',
  1102. 'argumentCount' => '1'
  1103. ),
  1104. 'NORMSINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1105. 'functionCall' => 'PHPExcel_Calculation_Functions::NORMSINV',
  1106. 'argumentCount' => '1'
  1107. ),
  1108. 'NOT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  1109. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGICAL_NOT',
  1110. 'argumentCount' => '1'
  1111. ),
  1112. 'NOW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1113. 'functionCall' => 'PHPExcel_Calculation_Functions::DATETIMENOW',
  1114. 'argumentCount' => '0'
  1115. ),
  1116. 'NPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1117. 'functionCall' => 'PHPExcel_Calculation_Functions::NPER',
  1118. 'argumentCount' => '3-5'
  1119. ),
  1120. 'NPV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1121. 'functionCall' => 'PHPExcel_Calculation_Functions::NPV',
  1122. 'argumentCount' => '2+'
  1123. ),
  1124. 'OCT2BIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  1125. 'functionCall' => 'PHPExcel_Calculation_Functions::OCTTOBIN',
  1126. 'argumentCount' => '1,2'
  1127. ),
  1128. 'OCT2DEC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  1129. 'functionCall' => 'PHPExcel_Calculation_Functions::OCTTODEC',
  1130. 'argumentCount' => '1'
  1131. ),
  1132. 'OCT2HEX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_ENGINEERING,
  1133. 'functionCall' => 'PHPExcel_Calculation_Functions::OCTTOHEX',
  1134. 'argumentCount' => '1,2'
  1135. ),
  1136. 'ODD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1137. 'functionCall' => 'PHPExcel_Calculation_Functions::ODD',
  1138. 'argumentCount' => '1'
  1139. ),
  1140. 'ODDFPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1141. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1142. 'argumentCount' => '8,9'
  1143. ),
  1144. 'ODDFYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1145. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1146. 'argumentCount' => '8,9'
  1147. ),
  1148. 'ODDLPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1149. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1150. 'argumentCount' => '7,8'
  1151. ),
  1152. 'ODDLYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1153. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1154. 'argumentCount' => '7,8'
  1155. ),
  1156. 'OFFSET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1157. 'functionCall' => 'PHPExcel_Calculation_Functions::OFFSET',
  1158. 'argumentCount' => '3,5',
  1159. 'passCellReference'=> true,
  1160. 'passByReference' => array(true)
  1161. ),
  1162. 'OR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  1163. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGICAL_OR',
  1164. 'argumentCount' => '1+'
  1165. ),
  1166. 'PEARSON' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1167. 'functionCall' => 'PHPExcel_Calculation_Functions::CORREL',
  1168. 'argumentCount' => '2'
  1169. ),
  1170. 'PERCENTILE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1171. 'functionCall' => 'PHPExcel_Calculation_Functions::PERCENTILE',
  1172. 'argumentCount' => '2'
  1173. ),
  1174. 'PERCENTRANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1175. 'functionCall' => 'PHPExcel_Calculation_Functions::PERCENTRANK',
  1176. 'argumentCount' => '2,3'
  1177. ),
  1178. 'PERMUT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1179. 'functionCall' => 'PHPExcel_Calculation_Functions::PERMUT',
  1180. 'argumentCount' => '2'
  1181. ),
  1182. 'PHONETIC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1183. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1184. 'argumentCount' => '1'
  1185. ),
  1186. 'PI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1187. 'functionCall' => 'pi',
  1188. 'argumentCount' => '0'
  1189. ),
  1190. 'PMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1191. 'functionCall' => 'PHPExcel_Calculation_Functions::PMT',
  1192. 'argumentCount' => '3-5'
  1193. ),
  1194. 'POISSON' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1195. 'functionCall' => 'PHPExcel_Calculation_Functions::POISSON',
  1196. 'argumentCount' => '3'
  1197. ),
  1198. 'POWER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1199. 'functionCall' => 'PHPExcel_Calculation_Functions::POWER',
  1200. 'argumentCount' => '2'
  1201. ),
  1202. 'PPMT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1203. 'functionCall' => 'PHPExcel_Calculation_Functions::PPMT',
  1204. 'argumentCount' => '4-6'
  1205. ),
  1206. 'PRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1207. 'functionCall' => 'PHPExcel_Calculation_Functions::PRICE',
  1208. 'argumentCount' => '6,7'
  1209. ),
  1210. 'PRICEDISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1211. 'functionCall' => 'PHPExcel_Calculation_Functions::PRICEDISC',
  1212. 'argumentCount' => '4,5'
  1213. ),
  1214. 'PRICEMAT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1215. 'functionCall' => 'PHPExcel_Calculation_Functions::PRICEMAT',
  1216. 'argumentCount' => '5,6'
  1217. ),
  1218. 'PROB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1219. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1220. 'argumentCount' => '3,4'
  1221. ),
  1222. 'PRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1223. 'functionCall' => 'PHPExcel_Calculation_Functions::PRODUCT',
  1224. 'argumentCount' => '1+'
  1225. ),
  1226. 'PROPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1227. 'functionCall' => 'PHPExcel_Calculation_Functions::PROPERCASE',
  1228. 'argumentCount' => '1'
  1229. ),
  1230. 'PV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1231. 'functionCall' => 'PHPExcel_Calculation_Functions::PV',
  1232. 'argumentCount' => '3-5'
  1233. ),
  1234. 'QUARTILE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1235. 'functionCall' => 'PHPExcel_Calculation_Functions::QUARTILE',
  1236. 'argumentCount' => '2'
  1237. ),
  1238. 'QUOTIENT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1239. 'functionCall' => 'PHPExcel_Calculation_Functions::QUOTIENT',
  1240. 'argumentCount' => '2'
  1241. ),
  1242. 'RADIANS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1243. 'functionCall' => 'deg2rad',
  1244. 'argumentCount' => '1'
  1245. ),
  1246. 'RAND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1247. 'functionCall' => 'PHPExcel_Calculation_Functions::RAND',
  1248. 'argumentCount' => '0'
  1249. ),
  1250. 'RANDBETWEEN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1251. 'functionCall' => 'PHPExcel_Calculation_Functions::RAND',
  1252. 'argumentCount' => '2'
  1253. ),
  1254. 'RANK' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1255. 'functionCall' => 'PHPExcel_Calculation_Functions::RANK',
  1256. 'argumentCount' => '2,3'
  1257. ),
  1258. 'RATE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1259. 'functionCall' => 'PHPExcel_Calculation_Functions::RATE',
  1260. 'argumentCount' => '3-6'
  1261. ),
  1262. 'RECEIVED' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1263. 'functionCall' => 'PHPExcel_Calculation_Functions::RECEIVED',
  1264. 'argumentCount' => '4-5'
  1265. ),
  1266. 'REPLACE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1267. 'functionCall' => 'PHPExcel_Calculation_Functions::REPLACE',
  1268. 'argumentCount' => '4'
  1269. ),
  1270. 'REPLACEB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1271. 'functionCall' => 'PHPExcel_Calculation_Functions::REPLACE',
  1272. 'argumentCount' => '4'
  1273. ),
  1274. 'REPT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1275. 'functionCall' => 'str_repeat',
  1276. 'argumentCount' => '2'
  1277. ),
  1278. 'RIGHT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1279. 'functionCall' => 'PHPExcel_Calculation_Functions::RIGHT',
  1280. 'argumentCount' => '1,2'
  1281. ),
  1282. 'RIGHTB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1283. 'functionCall' => 'PHPExcel_Calculation_Functions::RIGHT',
  1284. 'argumentCount' => '1,2'
  1285. ),
  1286. 'ROMAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1287. 'functionCall' => 'PHPExcel_Calculation_Functions::ROMAN',
  1288. 'argumentCount' => '1,2'
  1289. ),
  1290. 'ROUND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1291. 'functionCall' => 'round',
  1292. 'argumentCount' => '2'
  1293. ),
  1294. 'ROUNDDOWN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1295. 'functionCall' => 'PHPExcel_Calculation_Functions::ROUNDDOWN',
  1296. 'argumentCount' => '2'
  1297. ),
  1298. 'ROUNDUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1299. 'functionCall' => 'PHPExcel_Calculation_Functions::ROUNDUP',
  1300. 'argumentCount' => '2'
  1301. ),
  1302. 'ROW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1303. 'functionCall' => 'PHPExcel_Calculation_Functions::ROW',
  1304. 'argumentCount' => '-1',
  1305. 'passByReference' => array(true)
  1306. ),
  1307. 'ROWS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1308. 'functionCall' => 'PHPExcel_Calculation_Functions::ROWS',
  1309. 'argumentCount' => '1'
  1310. ),
  1311. 'RSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1312. 'functionCall' => 'PHPExcel_Calculation_Functions::RSQ',
  1313. 'argumentCount' => '2'
  1314. ),
  1315. 'RTD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1316. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1317. 'argumentCount' => '1+'
  1318. ),
  1319. 'SEARCH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1320. 'functionCall' => 'PHPExcel_Calculation_Functions::SEARCHINSENSITIVE',
  1321. 'argumentCount' => '2,3'
  1322. ),
  1323. 'SEARCHB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1324. 'functionCall' => 'PHPExcel_Calculation_Functions::SEARCHINSENSITIVE',
  1325. 'argumentCount' => '2,3'
  1326. ),
  1327. 'SECOND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1328. 'functionCall' => 'PHPExcel_Calculation_Functions::SECONDOFMINUTE',
  1329. 'argumentCount' => '1'
  1330. ),
  1331. 'SERIESSUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1332. 'functionCall' => 'PHPExcel_Calculation_Functions::SERIESSUM',
  1333. 'argumentCount' => '4'
  1334. ),
  1335. 'SIGN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1336. 'functionCall' => 'PHPExcel_Calculation_Functions::SIGN',
  1337. 'argumentCount' => '1'
  1338. ),
  1339. 'SIN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1340. 'functionCall' => 'sin',
  1341. 'argumentCount' => '1'
  1342. ),
  1343. 'SINH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1344. 'functionCall' => 'sinh',
  1345. 'argumentCount' => '1'
  1346. ),
  1347. 'SKEW' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1348. 'functionCall' => 'PHPExcel_Calculation_Functions::SKEW',
  1349. 'argumentCount' => '1+'
  1350. ),
  1351. 'SLN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1352. 'functionCall' => 'PHPExcel_Calculation_Functions::SLN',
  1353. 'argumentCount' => '3'
  1354. ),
  1355. 'SLOPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1356. 'functionCall' => 'PHPExcel_Calculation_Functions::SLOPE',
  1357. 'argumentCount' => '2'
  1358. ),
  1359. 'SMALL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1360. 'functionCall' => 'PHPExcel_Calculation_Functions::SMALL',
  1361. 'argumentCount' => '2'
  1362. ),
  1363. 'SQRT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1364. 'functionCall' => 'sqrt',
  1365. 'argumentCount' => '1'
  1366. ),
  1367. 'SQRTPI' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1368. 'functionCall' => 'PHPExcel_Calculation_Functions::SQRTPI',
  1369. 'argumentCount' => '1'
  1370. ),
  1371. 'STANDARDIZE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1372. 'functionCall' => 'PHPExcel_Calculation_Functions::STANDARDIZE',
  1373. 'argumentCount' => '3'
  1374. ),
  1375. 'STDEV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1376. 'functionCall' => 'PHPExcel_Calculation_Functions::STDEV',
  1377. 'argumentCount' => '1+'
  1378. ),
  1379. 'STDEVA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1380. 'functionCall' => 'PHPExcel_Calculation_Functions::STDEVA',
  1381. 'argumentCount' => '1+'
  1382. ),
  1383. 'STDEVP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1384. 'functionCall' => 'PHPExcel_Calculation_Functions::STDEVP',
  1385. 'argumentCount' => '1+'
  1386. ),
  1387. 'STDEVPA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1388. 'functionCall' => 'PHPExcel_Calculation_Functions::STDEVPA',
  1389. 'argumentCount' => '1+'
  1390. ),
  1391. 'STEYX' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1392. 'functionCall' => 'PHPExcel_Calculation_Functions::STEYX',
  1393. 'argumentCount' => '2'
  1394. ),
  1395. 'SUBSTITUTE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1396. 'functionCall' => 'PHPExcel_Calculation_Functions::SUBSTITUTE',
  1397. 'argumentCount' => '3,4'
  1398. ),
  1399. 'SUBTOTAL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1400. 'functionCall' => 'PHPExcel_Calculation_Functions::SUBTOTAL',
  1401. 'argumentCount' => '2+'
  1402. ),
  1403. 'SUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1404. 'functionCall' => 'PHPExcel_Calculation_Functions::SUM',
  1405. 'argumentCount' => '1+'
  1406. ),
  1407. 'SUMIF' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1408. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMIF',
  1409. 'argumentCount' => '2,3'
  1410. ),
  1411. 'SUMIFS' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1412. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1413. 'argumentCount' => '?'
  1414. ),
  1415. 'SUMPRODUCT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1416. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMPRODUCT',
  1417. 'argumentCount' => '1+'
  1418. ),
  1419. 'SUMSQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1420. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMSQ',
  1421. 'argumentCount' => '1+'
  1422. ),
  1423. 'SUMX2MY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1424. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMX2MY2',
  1425. 'argumentCount' => '2'
  1426. ),
  1427. 'SUMX2PY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1428. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMX2PY2',
  1429. 'argumentCount' => '2'
  1430. ),
  1431. 'SUMXMY2' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1432. 'functionCall' => 'PHPExcel_Calculation_Functions::SUMXMY2',
  1433. 'argumentCount' => '2'
  1434. ),
  1435. 'SYD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1436. 'functionCall' => 'PHPExcel_Calculation_Functions::SYD',
  1437. 'argumentCount' => '4'
  1438. ),
  1439. 'T' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1440. 'functionCall' => 'PHPExcel_Calculation_Functions::RETURNSTRING',
  1441. 'argumentCount' => '1'
  1442. ),
  1443. 'TAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1444. 'functionCall' => 'tan',
  1445. 'argumentCount' => '1'
  1446. ),
  1447. 'TANH' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1448. 'functionCall' => 'tanh',
  1449. 'argumentCount' => '1'
  1450. ),
  1451. 'TBILLEQ' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1452. 'functionCall' => 'PHPExcel_Calculation_Functions::TBILLEQ',
  1453. 'argumentCount' => '3'
  1454. ),
  1455. 'TBILLPRICE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1456. 'functionCall' => 'PHPExcel_Calculation_Functions::TBILLPRICE',
  1457. 'argumentCount' => '3'
  1458. ),
  1459. 'TBILLYIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1460. 'functionCall' => 'PHPExcel_Calculation_Functions::TBILLYIELD',
  1461. 'argumentCount' => '3'
  1462. ),
  1463. 'TDIST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1464. 'functionCall' => 'PHPExcel_Calculation_Functions::TDIST',
  1465. 'argumentCount' => '3'
  1466. ),
  1467. 'TEXT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1468. 'functionCall' => 'PHPExcel_Calculation_Functions::TEXTFORMAT',
  1469. 'argumentCount' => '2'
  1470. ),
  1471. 'TIME' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1472. 'functionCall' => 'PHPExcel_Calculation_Functions::TIME',
  1473. 'argumentCount' => '3'
  1474. ),
  1475. 'TIMEVALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1476. 'functionCall' => 'PHPExcel_Calculation_Functions::TIMEVALUE',
  1477. 'argumentCount' => '1'
  1478. ),
  1479. 'TINV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1480. 'functionCall' => 'PHPExcel_Calculation_Functions::TINV',
  1481. 'argumentCount' => '2'
  1482. ),
  1483. 'TODAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1484. 'functionCall' => 'PHPExcel_Calculation_Functions::DATENOW',
  1485. 'argumentCount' => '0'
  1486. ),
  1487. 'TRANSPOSE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1488. 'functionCall' => 'PHPExcel_Calculation_Functions::TRANSPOSE',
  1489. 'argumentCount' => '1'
  1490. ),
  1491. 'TREND' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1492. 'functionCall' => 'PHPExcel_Calculation_Functions::TREND',
  1493. 'argumentCount' => '1-4'
  1494. ),
  1495. 'TRIM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1496. 'functionCall' => 'PHPExcel_Calculation_Functions::TRIMSPACES',
  1497. 'argumentCount' => '1'
  1498. ),
  1499. 'TRIMMEAN' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1500. 'functionCall' => 'PHPExcel_Calculation_Functions::TRIMMEAN',
  1501. 'argumentCount' => '2'
  1502. ),
  1503. 'TRUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOGICAL,
  1504. 'functionCall' => 'PHPExcel_Calculation_Functions::LOGICAL_TRUE',
  1505. 'argumentCount' => '0'
  1506. ),
  1507. 'TRUNC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_MATH_AND_TRIG,
  1508. 'functionCall' => 'PHPExcel_Calculation_Functions::TRUNC',
  1509. 'argumentCount' => '1,2'
  1510. ),
  1511. 'TTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1512. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1513. 'argumentCount' => '4'
  1514. ),
  1515. 'TYPE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  1516. 'functionCall' => 'PHPExcel_Calculation_Functions::TYPE',
  1517. 'argumentCount' => '1'
  1518. ),
  1519. 'UPPER' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1520. 'functionCall' => 'PHPExcel_Calculation_Functions::UPPERCASE',
  1521. 'argumentCount' => '1'
  1522. ),
  1523. 'USDOLLAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1524. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1525. 'argumentCount' => '2'
  1526. ),
  1527. 'VALUE' => array('category' => PHPExcel_Calculation_Function::CATEGORY_TEXT_AND_DATA,
  1528. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1529. 'argumentCount' => '1'
  1530. ),
  1531. 'VAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1532. 'functionCall' => 'PHPExcel_Calculation_Functions::VARFunc',
  1533. 'argumentCount' => '1+'
  1534. ),
  1535. 'VARA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1536. 'functionCall' => 'PHPExcel_Calculation_Functions::VARA',
  1537. 'argumentCount' => '1+'
  1538. ),
  1539. 'VARP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1540. 'functionCall' => 'PHPExcel_Calculation_Functions::VARP',
  1541. 'argumentCount' => '1+'
  1542. ),
  1543. 'VARPA' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1544. 'functionCall' => 'PHPExcel_Calculation_Functions::VARPA',
  1545. 'argumentCount' => '1+'
  1546. ),
  1547. 'VDB' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1548. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1549. 'argumentCount' => '5-7'
  1550. ),
  1551. 'VERSION' => array('category' => PHPExcel_Calculation_Function::CATEGORY_INFORMATION,
  1552. 'functionCall' => 'PHPExcel_Calculation_Functions::VERSION',
  1553. 'argumentCount' => '0'
  1554. ),
  1555. 'VLOOKUP' => array('category' => PHPExcel_Calculation_Function::CATEGORY_LOOKUP_AND_REFERENCE,
  1556. 'functionCall' => 'PHPExcel_Calculation_Functions::VLOOKUP',
  1557. 'argumentCount' => '3,4'
  1558. ),
  1559. 'WEEKDAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1560. 'functionCall' => 'PHPExcel_Calculation_Functions::DAYOFWEEK',
  1561. 'argumentCount' => '1,2'
  1562. ),
  1563. 'WEEKNUM' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1564. 'functionCall' => 'PHPExcel_Calculation_Functions::WEEKOFYEAR',
  1565. 'argumentCount' => '1,2'
  1566. ),
  1567. 'WEIBULL' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1568. 'functionCall' => 'PHPExcel_Calculation_Functions::WEIBULL',
  1569. 'argumentCount' => '4'
  1570. ),
  1571. 'WORKDAY' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1572. 'functionCall' => 'PHPExcel_Calculation_Functions::WORKDAY',
  1573. 'argumentCount' => '2+'
  1574. ),
  1575. 'XIRR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1576. 'functionCall' => 'PHPExcel_Calculation_Functions::XIRR',
  1577. 'argumentCount' => '2,3'
  1578. ),
  1579. 'XNPV' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1580. 'functionCall' => 'PHPExcel_Calculation_Functions::XNPV',
  1581. 'argumentCount' => '3'
  1582. ),
  1583. 'YEAR' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1584. 'functionCall' => 'PHPExcel_Calculation_Functions::YEAR',
  1585. 'argumentCount' => '1'
  1586. ),
  1587. 'YEARFRAC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATE_AND_TIME,
  1588. 'functionCall' => 'PHPExcel_Calculation_Functions::YEARFRAC',
  1589. 'argumentCount' => '2,3'
  1590. ),
  1591. 'YIELD' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1592. 'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
  1593. 'argumentCount' => '6,7'
  1594. ),
  1595. 'YIELDDISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1596. 'functionCall' => 'PHPExcel_Calculation_Functions::YIELDDISC',
  1597. 'argumentCount' => '4,5'
  1598. ),
  1599. 'YIELDMAT' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,
  1600. 'functionCall' => 'PHPExcel_Calculation_Functions::YIELDMAT',
  1601. 'argumentCount' => '5,6'
  1602. ),
  1603. 'ZTEST' => array('category' => PHPExcel_Calculation_Function::CATEGORY_STATISTICAL,
  1604. 'functionCall' => 'PHPExcel_Calculation_Functions::ZTEST',
  1605. 'argumentCount' => '2-3'
  1606. )
  1607. );
  1608. // Internal functions used for special control purposes
  1609. private static $_controlFunctions = array(
  1610. 'MKMATRIX' => array('argumentCount' => '*',
  1611. 'functionCall' => 'self::_mkMatrix'
  1612. )
  1613. );
  1614. function __construct() {
  1615. $localeFileDirectory = PHPEXCEL_ROOT.'PHPExcel/locale/';
  1616. foreach (glob($localeFileDirectory.'/*',GLOB_ONLYDIR) as $filename) {
  1617. $filename = substr($filename,strlen($localeFileDirectory)+1);
  1618. if ($filename != 'en') {
  1619. self::$_validLocaleLanguages[] = $filename;
  1620. }
  1621. }
  1622. } // function __construct()
  1623. /**
  1624. * Get an instance of this class
  1625. *
  1626. * @access public
  1627. * @return PHPExcel_Calculation
  1628. */
  1629. public static function getInstance() {
  1630. if (!isset(self::$_instance) || is_null(self::$_instance)) {
  1631. self::$_instance = new PHPExcel_Calculation();
  1632. }
  1633. return self::$_instance;
  1634. } // function getInstance()
  1635. /**
  1636. * __clone implementation. Cloning should not be allowed in a Singleton!
  1637. *
  1638. * @access public
  1639. * @throws Exception
  1640. */
  1641. public final function __clone() {
  1642. throw new Exception ('Cloning a Singleton is not allowed!');
  1643. } // function __clone()
  1644. /**
  1645. * Set the Array Return Type (Array or Value of first element in the array)
  1646. *
  1647. * @access public
  1648. * @param string $returnType Array return type
  1649. * @return boolean Success or failure
  1650. */
  1651. public static function setArrayReturnType($returnType) {
  1652. if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||
  1653. ($returnType == self::RETURN_ARRAY_AS_ERROR) ||
  1654. ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {
  1655. self::$returnArrayAsType = $returnType;
  1656. return True;
  1657. }
  1658. return False;
  1659. } // function setExcelCalendar()
  1660. /**
  1661. * Return the Array Return Type (Array or Value of first element in the array)
  1662. *
  1663. * @access public
  1664. * @return string $returnType Array return type
  1665. */
  1666. public static function getArrayReturnType() {
  1667. return self::$returnArrayAsType;
  1668. } // function getExcelCalendar()
  1669. /**
  1670. * Is calculation caching enabled?
  1671. *
  1672. * @access public
  1673. * @return boolean
  1674. */
  1675. public function getCalculationCacheEnabled() {
  1676. return self::$_calculationCacheEnabled;
  1677. } // function getCalculationCacheEnabled()
  1678. /**
  1679. * Enable/disable calculation cache
  1680. *
  1681. * @access public
  1682. * @param boolean $pValue
  1683. */
  1684. public function setCalculationCacheEnabled($pValue = true) {
  1685. self::$_calculationCacheEnabled = $pValue;
  1686. $this->clearCalculationCache();
  1687. } // function setCalculationCacheEnabled()
  1688. /**
  1689. * Enable calculation cache
  1690. */
  1691. public function enableCalculationCache() {
  1692. $this->setCalculationCacheEnabled(true);
  1693. } // function enableCalculationCache()
  1694. /**
  1695. * Disable calculation cache
  1696. */
  1697. public function disableCalculationCache() {
  1698. $this->setCalculationCacheEnabled(false);
  1699. } // function disableCalculationCache()
  1700. /**
  1701. * Clear calculation cache
  1702. */
  1703. public function clearCalculationCache() {
  1704. self::$_calculationCache = array();
  1705. } // function clearCalculationCache()
  1706. /**
  1707. * Get calculation cache expiration time
  1708. *
  1709. * @return float
  1710. */
  1711. public function getCalculationCacheExpirationTime() {
  1712. return self::$_calculationCacheExpirationTime;
  1713. } // getCalculationCacheExpirationTime()
  1714. /**
  1715. * Set calculation cache expiration time
  1716. *
  1717. * @param float $pValue
  1718. */
  1719. public function setCalculationCacheExpirationTime($pValue = 2.5) {
  1720. self::$_calculationCacheExpirationTime = $pValue;
  1721. } // function setCalculationCacheExpirationTime()
  1722. /**
  1723. * Get the currently defined locale code
  1724. *
  1725. * @return string
  1726. */
  1727. public function getLocale() {
  1728. return self::$_localeLanguage;
  1729. } // function getLocale()
  1730. /**
  1731. * Set the locale code
  1732. *
  1733. * @return boolean
  1734. */
  1735. public function setLocale($locale='en_us') {
  1736. // Identify our locale and language
  1737. $language = $locale = strtolower($locale);
  1738. if (strpos($locale,'_') !== false) {
  1739. list($language) = explode('_',$locale);
  1740. }
  1741. // Test whether we have any language data for this language (any locale)
  1742. if (in_array($language,self::$_validLocaleLanguages)) {
  1743. // initialise language/locale settings
  1744. self::$_localeFunctions = array();
  1745. self::$_localeArgumentSeparator = ',';
  1746. self::$_localeBoolean = array('TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL');
  1747. // Default is English, if user isn't requesting english, then read the necessary data from the locale files
  1748. if ($locale != 'en_us') {
  1749. // Search for a file with a list of function names for locale
  1750. $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/functions';
  1751. if (!file_exists($functionNamesFile)) {
  1752. // If there isn't a locale specific function file, look for a language specific function file
  1753. $functionNamesFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/functions';
  1754. if (!file_exists($functionNamesFile)) {
  1755. return false;
  1756. }
  1757. }
  1758. // Retrieve the list of locale or language specific function names
  1759. $localeFunctions = file($functionNamesFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  1760. foreach ($localeFunctions as $localeFunction) {
  1761. list($localeFunction) = explode('##',$localeFunction); // Strip out comments
  1762. if (strpos($localeFunction,'=') !== false) {
  1763. list($fName,$lfName) = explode('=',$localeFunction);
  1764. $fName = trim($fName);
  1765. $lfName = trim($lfName);
  1766. if ((isset(self::$_PHPExcelFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {
  1767. self::$_localeFunctions[$fName] = $lfName;
  1768. }
  1769. }
  1770. }
  1771. // Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions
  1772. if (isset(self::$_localeFunctions['TRUE'])) { self::$_localeBoolean['TRUE'] = self::$_localeFunctions['TRUE']; }
  1773. if (isset(self::$_localeFunctions['FALSE'])) { self::$_localeBoolean['FALSE'] = self::$_localeFunctions['FALSE']; }
  1774. $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.str_replace('_','/',$locale).'/config';
  1775. if (!file_exists($configFile)) {
  1776. $configFile = PHPEXCEL_ROOT . 'PHPExcel/locale/'.$language.'/config';
  1777. }
  1778. if (file_exists($configFile)) {
  1779. $localeSettings = file($configFile,FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  1780. foreach ($localeSettings as $localeSetting) {
  1781. list($localeSetting) = explode('##',$localeSetting); // Strip out comments
  1782. if (strpos($localeSetting,'=') !== false) {
  1783. list($settingName,$settingValue) = explode('=',$localeSetting);
  1784. $settingName = strtoupper(trim($settingName));
  1785. switch ($settingName) {
  1786. case 'ARGUMENTSEPARATOR' :
  1787. self::$_localeArgumentSeparator = trim($settingValue);
  1788. break;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. }
  1794. self::$functionReplaceFromExcel = self::$functionReplaceToExcel =
  1795. self::$functionReplaceFromLocale = self::$functionReplaceToLocale = NULL;
  1796. self::$_localeLanguage = $locale;
  1797. return true;
  1798. }
  1799. return false;
  1800. } // function setLocale()
  1801. public static function _translateSeparator($fromSeparator,$toSeparator,$formula,&$inBraces) {
  1802. $strlen = mb_strlen($formula);
  1803. for ($i = 0; $i < $strlen; ++$i) {
  1804. $chr = mb_substr($formula,$i,1);
  1805. switch ($chr) {
  1806. case '{' : $inBraces = True;
  1807. break;
  1808. case '}' : $inBraces = False;
  1809. break;
  1810. case $fromSeparator :
  1811. if (!$inBraces) {
  1812. $formula = mb_substr($formula,0,$i).$toSeparator.mb_substr($formula,$i+1);
  1813. }
  1814. }
  1815. }
  1816. return $formula;
  1817. }
  1818. private static function _translateFormula($from,$to,$formula,$fromSeparator,$toSeparator) {
  1819. $inBraces = False;
  1820. // Convert any Excel function names to the required language
  1821. if (self::$_localeLanguage !== 'en_us') {
  1822. // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
  1823. if (strpos($formula,'"') !== false) {
  1824. // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
  1825. // the formula
  1826. $temp = explode('"',$formula);
  1827. foreach($temp as $i => &$value) {
  1828. // Only count/replace in alternate array entries
  1829. if (($i % 2) == 0) {
  1830. $value = preg_replace($from,$to,$value);
  1831. $value = self::_translateSeparator($fromSeparator,$toSeparator,$value,$inBraces);
  1832. }
  1833. }
  1834. unset($value);
  1835. // Then rebuild the formula string
  1836. $formula = implode('"',$temp);
  1837. } else {
  1838. // If there's no quoted strings, then we do a simple count/replace
  1839. $formula = preg_replace($from,$to,$formula);
  1840. $formula = self::_translateSeparator($fromSeparator,$toSeparator,$formula);
  1841. }
  1842. }
  1843. return $formula;
  1844. }
  1845. private static $functionReplaceFromExcel = NULL;
  1846. private static $functionReplaceToLocale = NULL;
  1847. public function _translateFormulaToLocale($formula) {
  1848. if (is_null(self::$functionReplaceFromExcel)) {
  1849. self::$functionReplaceFromExcel = array();
  1850. foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
  1851. self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelFunctionName).'([\s]*\()/Ui';
  1852. }
  1853. foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
  1854. self::$functionReplaceFromExcel[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
  1855. }
  1856. }
  1857. if (is_null(self::$functionReplaceToLocale)) {
  1858. self::$functionReplaceToLocale = array();
  1859. foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
  1860. self::$functionReplaceToLocale[] = '$1'.trim($localeFunctionName).'$2';
  1861. }
  1862. foreach(array_values(self::$_localeBoolean) as $localeBoolean) {
  1863. self::$functionReplaceToLocale[] = '$1'.trim($localeBoolean).'$2';
  1864. }
  1865. }
  1866. return self::_translateFormula(self::$functionReplaceFromExcel,self::$functionReplaceToLocale,$formula,',',self::$_localeArgumentSeparator);
  1867. } // function _translateFormulaToLocale()
  1868. private static $functionReplaceFromLocale = NULL;
  1869. private static $functionReplaceToExcel = NULL;
  1870. public function _translateFormulaToEnglish($formula) {
  1871. if (is_null(self::$functionReplaceFromLocale)) {
  1872. self::$functionReplaceFromLocale = array();
  1873. foreach(array_values(self::$_localeFunctions) as $localeFunctionName) {
  1874. self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($localeFunctionName).'([\s]*\()/Ui';
  1875. }
  1876. foreach(array_values(self::$_localeBoolean) as $excelBoolean) {
  1877. self::$functionReplaceFromLocale[] = '/(@?[^\w\.])'.preg_quote($excelBoolean).'([^\w\.])/Ui';
  1878. }
  1879. }
  1880. if (is_null(self::$functionReplaceToExcel)) {
  1881. self::$functionReplaceToExcel = array();
  1882. foreach(array_keys(self::$_localeFunctions) as $excelFunctionName) {
  1883. self::$functionReplaceToExcel[] = '$1'.trim($excelFunctionName).'$2';
  1884. }
  1885. foreach(array_keys(self::$_localeBoolean) as $excelBoolean) {
  1886. self::$functionReplaceToExcel[] = '$1'.trim($excelBoolean).'$2';
  1887. }
  1888. }
  1889. return self::_translateFormula(self::$functionReplaceFromLocale,self::$functionReplaceToExcel,$formula,self::$_localeArgumentSeparator,',');
  1890. } // function _translateFormulaToEnglish()
  1891. public static function _localeFunc($function) {
  1892. if (self::$_localeLanguage !== 'en_us') {
  1893. $functionName = trim($function,'(');
  1894. if (isset(self::$_localeFunctions[$functionName])) {
  1895. $brace = ($functionName != $function);
  1896. $function = self::$_localeFunctions[$functionName];
  1897. if ($brace) { $function .= '('; }
  1898. }
  1899. }
  1900. return $function;
  1901. }
  1902. /**
  1903. * Wrap string values in quotes
  1904. *
  1905. * @param mixed $value
  1906. * @return mixed
  1907. */
  1908. public static function _wrapResult($value) {
  1909. if (is_string($value)) {
  1910. // Error values cannot be "wrapped"
  1911. if (preg_match('/^'.self::CALCULATION_REGEXP_ERROR.'$/i', $value, $match)) {
  1912. // Return Excel errors "as is"
  1913. return $value;
  1914. }
  1915. // Return strings wrapped in quotes
  1916. return '"'.$value.'"';
  1917. // Convert numeric errors to NaN error
  1918. } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
  1919. return PHPExcel_Calculation_Functions::NaN();
  1920. }
  1921. return $value;
  1922. } // function _wrapResult()
  1923. /**
  1924. * Remove quotes used as a wrapper to identify string values
  1925. *
  1926. * @param mixed $value
  1927. * @return mixed
  1928. */
  1929. public static function _unwrapResult($value) {
  1930. if (is_string($value)) {
  1931. if ((strlen($value) > 0) && ($value{0} == '"') && (substr($value,-1) == '"')) {
  1932. return substr($value,1,-1);
  1933. }
  1934. // Convert numeric errors to NaN error
  1935. } else if((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {
  1936. return PHPExcel_Calculation_Functions::NaN();
  1937. }
  1938. return $value;
  1939. } // function _unwrapResult()
  1940. /**
  1941. * Calculate cell value (using formula from a cell ID)
  1942. * Retained for backward compatibility
  1943. *
  1944. * @access public
  1945. * @param PHPExcel_Cell $pCell Cell to calculate
  1946. * @return mixed
  1947. * @throws Exception
  1948. */
  1949. public function calculate(PHPExcel_Cell $pCell = null) {
  1950. try {
  1951. return $this->calculateCellValue($pCell);
  1952. } catch (Exception $e) {
  1953. throw(new Exception($e->getMessage()));
  1954. }
  1955. } // function calculate()
  1956. /**
  1957. * Calculate the value of a cell formula
  1958. *
  1959. * @access public
  1960. * @param PHPExcel_Cell $pCell Cell to calculate
  1961. * @param Boolean $resetLog Flag indicating whether the debug log should be reset or not
  1962. * @return mixed
  1963. * @throws Exception
  1964. */
  1965. public function calculateCellValue(PHPExcel_Cell $pCell = null, $resetLog = true) {
  1966. if ($resetLog) {
  1967. // Initialise the logging settings if requested
  1968. $this->formulaError = null;
  1969. $this->debugLog = $this->debugLogStack = array();
  1970. $this->_cyclicFormulaCount = 1;
  1971. $returnArrayAsType = self::$returnArrayAsType;
  1972. self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY;
  1973. }
  1974. // Read the formula from the cell
  1975. if (is_null($pCell)) {
  1976. return null;
  1977. }
  1978. if ($resetLog) {
  1979. self::$returnArrayAsType = $returnArrayAsType;
  1980. }
  1981. // Execute the calculation for the cell formula
  1982. try {
  1983. $result = self::_unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));
  1984. } catch (Exception $e) {
  1985. throw(new Exception($e->getMessage()));
  1986. }
  1987. if ((is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
  1988. $testResult = PHPExcel_Calculation_Functions::flattenArray($result);
  1989. if (self::$returnArrayAsType == self::RETURN_ARRAY_AS_ERROR) {
  1990. return PHPExcel_Calculation_Functions::VALUE();
  1991. }
  1992. // If there's only a single cell in the array, then we allow it
  1993. if (count($testResult) != 1) {
  1994. // If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it
  1995. $r = array_keys($result);
  1996. $r = array_shift($r);
  1997. if (!is_numeric($r)) { return PHPExcel_Calculation_Functions::VALUE(); }
  1998. if (is_array($result[$r])) {
  1999. $c = array_keys($result[$r]);
  2000. $c = array_shift($c);
  2001. if (!is_numeric($c)) {
  2002. return PHPExcel_Calculation_Functions::VALUE();
  2003. }
  2004. }
  2005. }
  2006. $result = array_shift($testResult);
  2007. }
  2008. if (is_null($result)) {
  2009. return 0;
  2010. } elseif((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {
  2011. return PHPExcel_Calculation_Functions::NaN();
  2012. }
  2013. return $result;
  2014. } // function calculateCellValue(
  2015. /**
  2016. * Validate and parse a formula string
  2017. *
  2018. * @param string $formula Formula to parse
  2019. * @return array
  2020. * @throws Exception
  2021. */
  2022. public function parseFormula($formula) {
  2023. // Basic validation that this is indeed a formula
  2024. // We return an empty array if not
  2025. $formula = trim($formula);
  2026. if ((strlen($formula) == 0) || ($formula{0} != '=')) return array();
  2027. $formula = trim(substr($formula,1));
  2028. $formulaLength = strlen($formula);
  2029. if ($formulaLength < 1) return array();
  2030. // Parse the formula and return the token stack
  2031. return $this->_parseFormula($formula);
  2032. } // function parseFormula()
  2033. /**
  2034. * Calculate the value of a formula
  2035. *
  2036. * @param string $formula Formula to parse
  2037. * @return mixed
  2038. * @throws Exception
  2039. */
  2040. public function calculateFormula($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
  2041. // Initialise the logging settings
  2042. $this->formulaError = null;
  2043. $this->debugLog = $this->debugLogStack = array();
  2044. // Disable calculation cacheing because it only applies to cell calculations, not straight formulae
  2045. // But don't actually flush any cache
  2046. $resetCache = $this->getCalculationCacheEnabled();
  2047. self::$_calculationCacheEnabled = false;
  2048. // Execute the calculation
  2049. try {
  2050. $result = self::_unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));
  2051. } catch (Exception $e) {
  2052. throw(new Exception($e->getMessage()));
  2053. }
  2054. // Reset calculation cacheing to its previous state
  2055. self::$_calculationCacheEnabled = $resetCache;
  2056. return $result;
  2057. } // function calculateFormula()
  2058. /**
  2059. * Parse a cell formula and calculate its value
  2060. *
  2061. * @param string $formula The formula to parse and calculate
  2062. * @param string $cellID The ID (e.g. A3) of the cell that we are calculating
  2063. * @param PHPExcel_Cell $pCell Cell to calculate
  2064. * @return mixed
  2065. * @throws Exception
  2066. */
  2067. public function _calculateFormulaValue($formula, $cellID=null, PHPExcel_Cell $pCell = null) {
  2068. // echo '<b>'.$cellID.'</b><br />';
  2069. $cellValue = '';
  2070. // Basic validation that this is indeed a formula
  2071. // We simply return the "cell value" (formula) if not
  2072. $formula = trim($formula);
  2073. if ($formula{0} != '=') return self::_wrapResult($formula);
  2074. $formula = trim(substr($formula,1));
  2075. $formulaLength = strlen($formula);
  2076. if ($formulaLength < 1) return self::_wrapResult($formula);
  2077. $wsTitle = 'Wrk';
  2078. if (!is_null($pCell)) {
  2079. $pCellParent = $pCell->getParent();
  2080. if (!is_null($pCellParent)) {
  2081. $wsTitle = $pCellParent->getTitle();
  2082. }
  2083. }
  2084. // Is calculation cacheing enabled?
  2085. if (!is_null($cellID)) {
  2086. if (self::$_calculationCacheEnabled) {
  2087. // Is the value present in calculation cache?
  2088. // echo 'Testing cache value<br />';
  2089. if (isset(self::$_calculationCache[$wsTitle][$cellID])) {
  2090. // echo 'Value is in cache<br />';
  2091. $this->_writeDebug('Testing cache value for cell '.$cellID);
  2092. // Is cache still valid?
  2093. if ((time() + microtime(true)) - self::$_calculationCache[$wsTitle][$cellID]['time'] < self::$_calculationCacheExpirationTime) {
  2094. // echo 'Cache time is still valid<br />';
  2095. $this->_writeDebug('Retrieving value for '.$cellID.' from cache');
  2096. // Return the cached result
  2097. $returnValue = self::$_calculationCache[$wsTitle][$cellID]['data'];
  2098. // echo 'Retrieving data value of '.$returnValue.' for '.$cellID.' from cache<br />';
  2099. if (is_array($returnValue)) {
  2100. $returnValue = PHPExcel_Calculation_Functions::flattenArray($returnValue);
  2101. return array_shift($returnValue);
  2102. }
  2103. return $returnValue;
  2104. } else {
  2105. // echo 'Cache has expired<br />';
  2106. $this->_writeDebug('Cache value for '.$cellID.' has expired');
  2107. // Clear the cache if it's no longer valid
  2108. unset(self::$_calculationCache[$wsTitle][$cellID]);
  2109. }
  2110. }
  2111. }
  2112. }
  2113. if ((in_array($wsTitle.'!'.$cellID,$this->debugLogStack)) && ($wsTitle != 'Wrk')) {
  2114. if ($this->cyclicFormulaCount <= 0) {
  2115. return $this->_raiseFormulaError('Cyclic Reference in Formula');
  2116. } elseif (($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) &&
  2117. ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID)) {
  2118. return $cellValue;
  2119. } elseif ($this->_cyclicFormulaCell == $wsTitle.'!'.$cellID) {
  2120. $this->_cyclicFormulaCount++;
  2121. if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
  2122. return $cellValue;
  2123. }
  2124. } elseif ($this->_cyclicFormulaCell == '') {
  2125. $this->_cyclicFormulaCell = $wsTitle.'!'.$cellID;
  2126. if ($this->_cyclicFormulaCount >= $this->cyclicFormulaCount) {
  2127. return $cellValue;
  2128. }
  2129. }
  2130. }
  2131. $this->debugLogStack[] = $wsTitle.'!'.$cellID;
  2132. // Parse the formula onto the token stack and calculate the value
  2133. $cellValue = $this->_processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell);
  2134. array_pop($this->debugLogStack);
  2135. // Save to calculation cache
  2136. if (!is_null($cellID)) {
  2137. if (self::$_calculationCacheEnabled) {
  2138. self::$_calculationCache[$wsTitle][$cellID]['time'] = (time() + microtime(true));
  2139. self::$_calculationCache[$wsTitle][$cellID]['data'] = $cellValue;
  2140. }
  2141. }
  2142. // Return the calculated value
  2143. return $cellValue;
  2144. } // function _calculateFormulaValue()
  2145. /**
  2146. * Ensure that paired matrix operands are both matrices and of the same size
  2147. *
  2148. * @param mixed &$operand1 First matrix operand
  2149. * @param mixed &$operand2 Second matrix operand
  2150. * @param integer $resize Flag indicating whether the matrices should be resized to match
  2151. * and (if so), whether the smaller dimension should grow or the
  2152. * larger should shrink.
  2153. * 0 = no resize
  2154. * 1 = shrink to fit
  2155. * 2 = extend to fit
  2156. */
  2157. private static function _checkMatrixOperands(&$operand1,&$operand2,$resize = 1) {
  2158. // Examine each of the two operands, and turn them into an array if they aren't one already
  2159. // Note that this function should only be called if one or both of the operand is already an array
  2160. if (!is_array($operand1)) {
  2161. list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand2);
  2162. $operand1 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand1));
  2163. $resize = 0;
  2164. } elseif (!is_array($operand2)) {
  2165. list($matrixRows,$matrixColumns) = self::_getMatrixDimensions($operand1);
  2166. $operand2 = array_fill(0,$matrixRows,array_fill(0,$matrixColumns,$operand2));
  2167. $resize = 0;
  2168. }
  2169. list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($operand1);
  2170. list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($operand2);
  2171. if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) {
  2172. $resize = 1;
  2173. }
  2174. if ($resize == 2) {
  2175. // Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger
  2176. self::_resizeMatricesExtend($operand1,$operand2);
  2177. } elseif ($resize == 1) {
  2178. // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller
  2179. self::_resizeMatricesShrink($operand1,$operand2);
  2180. }
  2181. } // function _checkMatrixOperands()
  2182. /**
  2183. * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0
  2184. *
  2185. * @param mixed &$matrix matrix operand
  2186. * @return array An array comprising the number of rows, and number of columns
  2187. */
  2188. public static function _getMatrixDimensions(&$matrix) {
  2189. $matrixRows = count($matrix);
  2190. $matrixColumns = 0;
  2191. foreach($matrix as $rowKey => $rowValue) {
  2192. $colCount = count($rowValue);
  2193. if ($colCount > $matrixColumns) {
  2194. $matrixColumns = $colCount;
  2195. }
  2196. if (!is_array($rowValue)) {
  2197. $matrix[$rowKey] = array($rowValue);
  2198. } else {
  2199. $matrix[$rowKey] = array_values($rowValue);
  2200. }
  2201. }
  2202. $matrix = array_values($matrix);
  2203. return array($matrixRows,$matrixColumns);
  2204. } // function _getMatrixDimensions()
  2205. /**
  2206. * Ensure that paired matrix operands are both matrices of the same size
  2207. *
  2208. * @param mixed &$matrix1 First matrix operand
  2209. * @param mixed &$matrix2 Second matrix operand
  2210. */
  2211. private static function _resizeMatricesShrink(&$matrix1,&$matrix2) {
  2212. list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($matrix1);
  2213. list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($matrix2);
  2214. if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
  2215. if ($matrix2Columns < $matrix1Columns) {
  2216. for ($i = 0; $i < $matrix1Rows; ++$i) {
  2217. for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
  2218. unset($matrix1[$i][$j]);
  2219. }
  2220. }
  2221. }
  2222. if ($matrix2Rows < $matrix1Rows) {
  2223. for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) {
  2224. unset($matrix1[$i]);
  2225. }
  2226. }
  2227. }
  2228. if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
  2229. if ($matrix1Columns < $matrix2Columns) {
  2230. for ($i = 0; $i < $matrix2Rows; ++$i) {
  2231. for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
  2232. unset($matrix2[$i][$j]);
  2233. }
  2234. }
  2235. }
  2236. if ($matrix1Rows < $matrix2Rows) {
  2237. for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) {
  2238. unset($matrix2[$i]);
  2239. }
  2240. }
  2241. }
  2242. } // function _resizeMatricesShrink()
  2243. /**
  2244. * Ensure that paired matrix operands are both matrices of the same size
  2245. *
  2246. * @param mixed &$matrix1 First matrix operand
  2247. * @param mixed &$matrix2 Second matrix operand
  2248. */
  2249. private static function _resizeMatricesExtend(&$matrix1,&$matrix2) {
  2250. list($matrix1Rows,$matrix1Columns) = self::_getMatrixDimensions($matrix1);
  2251. list($matrix2Rows,$matrix2Columns) = self::_getMatrixDimensions($matrix2);
  2252. if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) {
  2253. if ($matrix2Columns < $matrix1Columns) {
  2254. for ($i = 0; $i < $matrix2Rows; ++$i) {
  2255. $x = $matrix2[$i][$matrix2Columns-1];
  2256. for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) {
  2257. $matrix2[$i][$j] = $x;
  2258. }
  2259. }
  2260. }
  2261. if ($matrix2Rows < $matrix1Rows) {
  2262. $x = $matrix2[$matrix2Rows-1];
  2263. for ($i = 0; $i < $matrix1Rows; ++$i) {
  2264. $matrix2[$i] = $x;
  2265. }
  2266. }
  2267. }
  2268. if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) {
  2269. if ($matrix1Columns < $matrix2Columns) {
  2270. for ($i = 0; $i < $matrix1Rows; ++$i) {
  2271. $x = $matrix1[$i][$matrix1Columns-1];
  2272. for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) {
  2273. $matrix1[$i][$j] = $x;
  2274. }
  2275. }
  2276. }
  2277. if ($matrix1Rows < $matrix2Rows) {
  2278. $x = $matrix1[$matrix1Rows-1];
  2279. for ($i = 0; $i < $matrix2Rows; ++$i) {
  2280. $matrix1[$i] = $x;
  2281. }
  2282. }
  2283. }
  2284. } // function _resizeMatricesExtend()
  2285. /**
  2286. * Format details of an operand for display in the log (based on operand type)
  2287. *
  2288. * @param mixed $value First matrix operand
  2289. * @return mixed
  2290. */
  2291. private static function _showValue($value) {
  2292. $testArray = PHPExcel_Calculation_Functions::flattenArray($value);
  2293. if (count($testArray) == 1) {
  2294. $value = array_pop($testArray);
  2295. }
  2296. if (is_array($value)) {
  2297. $returnMatrix = array();
  2298. $pad = $rpad = ', ';
  2299. foreach($value as $row) {
  2300. if (is_array($row)) {
  2301. $returnMatrix[] = implode($pad,$row);
  2302. $rpad = '; ';
  2303. } else {
  2304. $returnMatrix[] = $row;
  2305. }
  2306. }
  2307. return '{ '.implode($rpad,$returnMatrix).' }';
  2308. } elseif(is_bool($value)) {
  2309. return ($value) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
  2310. }
  2311. return $value;
  2312. } // function _showValue()
  2313. /**
  2314. * Format type and details of an operand for display in the log (based on operand type)
  2315. *
  2316. * @param mixed $value First matrix operand
  2317. * @return mixed
  2318. */
  2319. private static function _showTypeDetails($value) {
  2320. $testArray = PHPExcel_Calculation_Functions::flattenArray($value);
  2321. if (count($testArray) == 1) {
  2322. $value = array_pop($testArray);
  2323. }
  2324. if (is_null($value)) {
  2325. return 'a null value';
  2326. } elseif (is_float($value)) {
  2327. $typeString = 'a floating point number';
  2328. } elseif(is_int($value)) {
  2329. $typeString = 'an integer number';
  2330. } elseif(is_bool($value)) {
  2331. $typeString = 'a boolean';
  2332. } elseif(is_array($value)) {
  2333. $typeString = 'a matrix';
  2334. } else {
  2335. if ($value == '') {
  2336. return 'an empty string';
  2337. } elseif ($value{0} == '#') {
  2338. return 'a '.$value.' error';
  2339. } else {
  2340. $typeString = 'a string';
  2341. }
  2342. }
  2343. return $typeString.' with a value of '.self::_showValue($value);
  2344. } // function _showTypeDetails()
  2345. private static function _convertMatrixReferences($formula) {
  2346. static $matrixReplaceFrom = array('{',';','}');
  2347. static $matrixReplaceTo = array('MKMATRIX(MKMATRIX(','),MKMATRIX(','))');
  2348. // Convert any Excel matrix references to the MKMATRIX() function
  2349. if (strpos($formula,'{') !== false) {
  2350. // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
  2351. if (strpos($formula,'"') !== false) {
  2352. // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
  2353. // the formula
  2354. $temp = explode('"',$formula);
  2355. // Open and Closed counts used for trapping mismatched braces in the formula
  2356. $openCount = $closeCount = 0;
  2357. foreach($temp as $i => &$value) {
  2358. // Only count/replace in alternate array entries
  2359. if (($i % 2) == 0) {
  2360. $openCount += substr_count($value,'{');
  2361. $closeCount += substr_count($value,'}');
  2362. $value = str_replace($matrixReplaceFrom,$matrixReplaceTo,$value);
  2363. }
  2364. }
  2365. unset($value);
  2366. // Then rebuild the formula string
  2367. $formula = implode('"',$temp);
  2368. } else {
  2369. // If there's no quoted strings, then we do a simple count/replace
  2370. $openCount = substr_count($formula,'{');
  2371. $closeCount = substr_count($formula,'}');
  2372. $formula = str_replace($matrixReplaceFrom,$matrixReplaceTo,$formula);
  2373. }
  2374. // Trap for mismatched braces and trigger an appropriate error
  2375. if ($openCount < $closeCount) {
  2376. if ($openCount > 0) {
  2377. return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '}'");
  2378. } else {
  2379. return $this->_raiseFormulaError("Formula Error: Unexpected '}' encountered");
  2380. }
  2381. } elseif ($openCount > $closeCount) {
  2382. if ($closeCount > 0) {
  2383. return $this->_raiseFormulaError("Formula Error: Mismatched matrix braces '{'");
  2384. } else {
  2385. return $this->_raiseFormulaError("Formula Error: Unexpected '{' encountered");
  2386. }
  2387. }
  2388. }
  2389. return $formula;
  2390. } // function _convertMatrixReferences()
  2391. private static function _mkMatrix() {
  2392. return func_get_args();
  2393. } // function _mkMatrix()
  2394. // Convert infix to postfix notation
  2395. private function _parseFormula($formula, PHPExcel_Cell $pCell = null) {
  2396. if (($formula = self::_convertMatrixReferences(trim($formula))) === false) {
  2397. return false;
  2398. }
  2399. // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
  2400. // so we store the parent worksheet so that we can re-attach it when necessary
  2401. $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
  2402. // Binary Operators
  2403. // These operators always work on two values
  2404. // Array key is the operator, the value indicates whether this is a left or right associative operator
  2405. $operatorAssociativity = array('^' => 0, // Exponentiation
  2406. '*' => 0, '/' => 0, // Multiplication and Division
  2407. '+' => 0, '-' => 0, // Addition and Subtraction
  2408. '&' => 0, // Concatenation
  2409. '|' => 0, ':' => 0, // Intersect and Range
  2410. '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison
  2411. );
  2412. // Comparison (Boolean) Operators
  2413. // These operators work on two values, but always return a boolean result
  2414. $comparisonOperators = array('>', '<', '=', '>=', '<=', '<>');
  2415. // Operator Precedence
  2416. // This list includes all valid operators, whether binary (including boolean) or unary (such as %)
  2417. // Array key is the operator, the value is its precedence
  2418. $operatorPrecedence = array(':' => 8, // Range
  2419. '|' => 7, // Intersect
  2420. '~' => 6, // Negation
  2421. '%' => 5, // Percentage
  2422. '^' => 4, // Exponentiation
  2423. '*' => 3, '/' => 3, // Multiplication and Division
  2424. '+' => 2, '-' => 2, // Addition and Subtraction
  2425. '&' => 1, // Concatenation
  2426. '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0 // Comparison
  2427. );
  2428. $regexpMatchString = '/^('.self::CALCULATION_REGEXP_FUNCTION.
  2429. '|'.self::CALCULATION_REGEXP_NUMBER.
  2430. '|'.self::CALCULATION_REGEXP_STRING.
  2431. '|'.self::CALCULATION_REGEXP_OPENBRACE.
  2432. '|'.self::CALCULATION_REGEXP_CELLREF.
  2433. '|'.self::CALCULATION_REGEXP_NAMEDRANGE.
  2434. '|'.self::CALCULATION_REGEXP_ERROR.
  2435. ')/si';
  2436. // Start with initialisation
  2437. $index = 0;
  2438. $stack = new PHPExcel_Token_Stack;
  2439. $output = array();
  2440. $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a
  2441. // - is a negation or + is a positive operator rather than an operation
  2442. $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand
  2443. // should be null in a function call
  2444. // The guts of the lexical parser
  2445. // Loop through the formula extracting each operator and operand in turn
  2446. while(True) {
  2447. // echo 'Assessing Expression <b>'.substr($formula, $index).'</b><br />';
  2448. $opCharacter = $formula{$index}; // Get the first character of the value at the current index position
  2449. // echo 'Initial character of expression block is '.$opCharacter.'<br />';
  2450. if ((in_array($opCharacter, $comparisonOperators)) && (strlen($formula) > $index) && (in_array($formula{$index+1}, $comparisonOperators))) {
  2451. $opCharacter .= $formula{++$index};
  2452. // echo 'Initial character of expression block is comparison operator '.$opCharacter.'<br />';
  2453. }
  2454. // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand
  2455. $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match);
  2456. // echo '$isOperandOrFunction is '.(($isOperandOrFunction)?'True':'False').'<br />';
  2457. if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?
  2458. // echo 'Element is a Negation operator<br />';
  2459. $stack->push('Unary Operator','~'); // Put a negation on the stack
  2460. ++$index; // and drop the negation symbol
  2461. } elseif ($opCharacter == '%' && $expectingOperator) {
  2462. // echo 'Element is a Percentage operator<br />';
  2463. $stack->push('Unary Operator','%'); // Put a percentage on the stack
  2464. ++$index;
  2465. } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (rather than plus) can be discarded?
  2466. // echo 'Element is a Positive number, not Plus operator<br />';
  2467. ++$index; // Drop the redundant plus symbol
  2468. } elseif (($opCharacter == '~') && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde, because it's legal
  2469. return $this->_raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression
  2470. } elseif ((in_array($opCharacter, self::$_operators) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack?
  2471. // echo 'Element with value '.$opCharacter.' is an Operator<br />';
  2472. while($stack->count() > 0 &&
  2473. ($o2 = $stack->last()) &&
  2474. in_array($o2['value'], self::$_operators) &&
  2475. @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) {
  2476. $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
  2477. }
  2478. $stack->push('Binary Operator',$opCharacter); // Finally put our current operator onto the stack
  2479. ++$index;
  2480. $expectingOperator = false;
  2481. } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis?
  2482. // echo 'Element is a Closing bracket<br />';
  2483. $expectingOperand = false;
  2484. while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
  2485. if (is_null($o2)) return $this->_raiseFormulaError('Formula Error: Unexpected closing brace ")"');
  2486. else $output[] = $o2;
  2487. }
  2488. $d = $stack->last(2);
  2489. if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches)) { // Did this parenthesis just close a function?
  2490. $functionName = $matches[1]; // Get the function name
  2491. // echo 'Closed Function is '.$functionName.'<br />';
  2492. $d = $stack->pop();
  2493. $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack)
  2494. // if ($argumentCount == 0) {
  2495. // echo 'With no arguments<br />';
  2496. // } elseif ($argumentCount == 1) {
  2497. // echo 'With 1 argument<br />';
  2498. // } else {
  2499. // echo 'With '.$argumentCount.' arguments<br />';
  2500. // }
  2501. $output[] = $d; // Dump the argument count on the output
  2502. $output[] = $stack->pop(); // Pop the function and push onto the output
  2503. if (array_key_exists($functionName, self::$_controlFunctions)) {
  2504. // echo 'Built-in function '.$functionName.'<br />';
  2505. $expectedArgumentCount = self::$_controlFunctions[$functionName]['argumentCount'];
  2506. $functionCall = self::$_controlFunctions[$functionName]['functionCall'];
  2507. } elseif (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
  2508. // echo 'PHPExcel function '.$functionName.'<br />';
  2509. $expectedArgumentCount = self::$_PHPExcelFunctions[$functionName]['argumentCount'];
  2510. $functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
  2511. } else { // did we somehow push a non-function on the stack? this should never happen
  2512. return $this->_raiseFormulaError("Formula Error: Internal error, non-function on stack");
  2513. }
  2514. // Check the argument count
  2515. $argumentCountError = False;
  2516. if (is_numeric($expectedArgumentCount)) {
  2517. if ($expectedArgumentCount < 0) {
  2518. // echo '$expectedArgumentCount is between 0 and '.abs($expectedArgumentCount).'<br />';
  2519. if ($argumentCount > abs($expectedArgumentCount)) {
  2520. $argumentCountError = True;
  2521. $expectedArgumentCountString = 'no more than '.abs($expectedArgumentCount);
  2522. }
  2523. } else {
  2524. // echo '$expectedArgumentCount is numeric '.$expectedArgumentCount.'<br />';
  2525. if ($argumentCount != $expectedArgumentCount) {
  2526. $argumentCountError = True;
  2527. $expectedArgumentCountString = $expectedArgumentCount;
  2528. }
  2529. }
  2530. } elseif ($expectedArgumentCount != '*') {
  2531. $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/',$expectedArgumentCount,$argMatch);
  2532. // print_r($argMatch);
  2533. // echo '<br />';
  2534. switch ($argMatch[2]) {
  2535. case '+' :
  2536. if ($argumentCount < $argMatch[1]) {
  2537. $argumentCountError = True;
  2538. $expectedArgumentCountString = $argMatch[1].' or more ';
  2539. }
  2540. break;
  2541. case '-' :
  2542. if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) {
  2543. $argumentCountError = True;
  2544. $expectedArgumentCountString = 'between '.$argMatch[1].' and '.$argMatch[3];
  2545. }
  2546. break;
  2547. case ',' :
  2548. if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) {
  2549. $argumentCountError = True;
  2550. $expectedArgumentCountString = 'either '.$argMatch[1].' or '.$argMatch[3];
  2551. }
  2552. break;
  2553. }
  2554. }
  2555. if ($argumentCountError) {
  2556. return $this->_raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, ".$expectedArgumentCountString." expected");
  2557. }
  2558. }
  2559. ++$index;
  2560. } elseif ($opCharacter == ',') { // Is this the separator for function arguments?
  2561. // echo 'Element is a Function argument separator<br />';
  2562. while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last (
  2563. if (is_null($o2)) return $this->_raiseFormulaError("Formula Error: Unexpected ,");
  2564. else $output[] = $o2; // pop the argument expression stuff and push onto the output
  2565. }
  2566. // If we've a comma when we're expecting an operand, then what we actually have is a null operand;
  2567. // so push a null onto the stack
  2568. if (($expectingOperand) || (!$expectingOperator)) {
  2569. $output[] = array('type' => 'NULL Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
  2570. }
  2571. // make sure there was a function
  2572. $d = $stack->last(2);
  2573. if (!preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $d['value'], $matches))
  2574. return $this->_raiseFormulaError("Formula Error: Unexpected ,");
  2575. $d = $stack->pop();
  2576. $stack->push($d['type'],++$d['value'],$d['reference']); // increment the argument count
  2577. $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again
  2578. $expectingOperator = false;
  2579. $expectingOperand = true;
  2580. ++$index;
  2581. } elseif ($opCharacter == '(' && !$expectingOperator) {
  2582. // echo 'Element is an Opening Bracket<br />';
  2583. $stack->push('Brace', '(');
  2584. ++$index;
  2585. } elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number?
  2586. $expectingOperator = true;
  2587. $expectingOperand = false;
  2588. $val = $match[1];
  2589. $length = strlen($val);
  2590. // echo 'Element with value '.$val.' is an Operand, Variable, Constant, String, Number, Cell Reference or Function<br />';
  2591. if (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $val, $matches)) {
  2592. $val = preg_replace('/\s/','',$val);
  2593. // echo 'Element '.$val.' is a Function<br />';
  2594. if (array_key_exists(strtoupper($matches[1]), self::$_PHPExcelFunctions) || array_key_exists(strtoupper($matches[1]), self::$_controlFunctions)) { // it's a func
  2595. $stack->push('Function', strtoupper($val));
  2596. $ax = preg_match('/^\s*(\s*\))/i', substr($formula, $index+$length), $amatch);
  2597. if ($ax) {
  2598. $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 0);
  2599. $expectingOperator = true;
  2600. } else {
  2601. $stack->push('Operand Count for Function '.self::_localeFunc(strtoupper($val)).')', 1);
  2602. $expectingOperator = false;
  2603. }
  2604. $stack->push('Brace', '(');
  2605. } else { // it's a var w/ implicit multiplication
  2606. $output[] = array('type' => 'Value', 'value' => $matches[1], 'reference' => NULL);
  2607. }
  2608. } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $val, $matches)) {
  2609. // echo 'Element '.$val.' is a Cell reference<br />';
  2610. // Watch for this case-change when modifying to allow cell references in different worksheets...
  2611. // Should only be applied to the actual cell column, not the worksheet name
  2612. // If the last entry on the stack was a : operator, then we have a cell range reference
  2613. $testPrevOp = $stack->last(1);
  2614. if ($testPrevOp['value'] == ':') {
  2615. // If we have a worksheet reference, then we're playing with a 3D reference
  2616. if ($matches[2] == '') {
  2617. // Otherwise, we 'inherit' the worksheet reference from the start cell reference
  2618. // The start of the cell range reference should be the last entry in $output
  2619. $startCellRef = $output[count($output)-1]['value'];
  2620. preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $startCellRef, $startMatches);
  2621. if ($startMatches[2] > '') {
  2622. $val = $startMatches[2].'!'.$val;
  2623. }
  2624. }
  2625. }
  2626. $cellRef = strtoupper($val);
  2627. $output[] = array('type' => 'Cell Reference', 'value' => $val, 'reference' => $cellRef);
  2628. // $expectingOperator = false;
  2629. } else { // it's a variable, constant, string, number or boolean
  2630. // echo 'Element is a Variable, Constant, String, Number or Boolean<br />';
  2631. // If the last entry on the stack was a : operator, then we may have a row or column range reference
  2632. $testPrevOp = $stack->last(1);
  2633. if ($testPrevOp['value'] == ':') {
  2634. $startRowColRef = $output[count($output)-1]['value'];
  2635. $rangeWS1 = '';
  2636. if (strpos('!',$startRowColRef) !== false) {
  2637. list($rangeWS1,$startRowColRef) = explode('!',$startRowColRef);
  2638. }
  2639. if ($rangeWS1 != '') $rangeWS1 .= '!';
  2640. $rangeWS2 = $rangeWS1;
  2641. if (strpos('!',$val) !== false) {
  2642. list($rangeWS2,$val) = explode('!',$val);
  2643. }
  2644. if ($rangeWS2 != '') $rangeWS2 .= '!';
  2645. if ((is_integer($startRowColRef)) && (ctype_digit($val)) &&
  2646. ($startRowColRef <= 1048576) && ($val <= 1048576)) {
  2647. // Row range
  2648. $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007
  2649. $output[count($output)-1]['value'] = $rangeWS1.'A'.$startRowColRef;
  2650. $val = $rangeWS2.$endRowColRef.$val;
  2651. } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) &&
  2652. (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {
  2653. // Column range
  2654. $endRowColRef = (!is_null($pCellParent)) ? $pCellParent->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007
  2655. $output[count($output)-1]['value'] = $rangeWS1.strtoupper($startRowColRef).'1';
  2656. $val = $rangeWS2.$val.$endRowColRef;
  2657. }
  2658. }
  2659. $localeConstant = false;
  2660. if ($opCharacter == '"') {
  2661. // echo 'Element is a String<br />';
  2662. // UnEscape any quotes within the string
  2663. $val = self::_wrapResult(str_replace('""','"',self::_unwrapResult($val)));
  2664. } elseif (is_numeric($val)) {
  2665. // echo 'Element is a Number<br />';
  2666. if ((strpos($val,'.') !== False) || (stripos($val,'e') !== False) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) {
  2667. // echo 'Casting '.$val.' to float<br />';
  2668. $val = (float) $val;
  2669. } else {
  2670. // echo 'Casting '.$val.' to integer<br />';
  2671. $val = (integer) $val;
  2672. }
  2673. } elseif (array_key_exists(trim(strtoupper($val)), self::$_ExcelConstants)) {
  2674. $excelConstant = trim(strtoupper($val));
  2675. // echo 'Element '.$excelConstant.' is an Excel Constant<br />';
  2676. $val = self::$_ExcelConstants[$excelConstant];
  2677. } elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$_localeBoolean)) !== false) {
  2678. // echo 'Element '.$localeConstant.' is an Excel Constant<br />';
  2679. $val = self::$_ExcelConstants[$localeConstant];
  2680. }
  2681. $details = array('type' => 'Value', 'value' => $val, 'reference' => NULL);
  2682. if ($localeConstant) { $details['localeValue'] = $localeConstant; }
  2683. $output[] = $details;
  2684. }
  2685. $index += $length;
  2686. } elseif ($opCharacter == '$') { // absolute row or column range
  2687. $index++;
  2688. } elseif ($opCharacter == ')') { // miscellaneous error checking
  2689. if ($expectingOperand) {
  2690. $output[] = array('type' => 'Null Value', 'value' => self::$_ExcelConstants['NULL'], 'reference' => NULL);
  2691. $expectingOperand = false;
  2692. $expectingOperator = True;
  2693. } else {
  2694. return $this->_raiseFormulaError("Formula Error: Unexpected ')'");
  2695. }
  2696. } elseif (in_array($opCharacter, self::$_operators) && !$expectingOperator) {
  2697. return $this->_raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'");
  2698. } else { // I don't even want to know what you did to get here
  2699. return $this->_raiseFormulaError("Formula Error: An unexpected error occured");
  2700. }
  2701. // Test for end of formula string
  2702. if ($index == strlen($formula)) {
  2703. // Did we end with an operator?.
  2704. // Only valid for the % unary operator
  2705. if ((in_array($opCharacter, self::$_operators)) && ($opCharacter != '%')) {
  2706. return $this->_raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands");
  2707. } else {
  2708. break;
  2709. }
  2710. }
  2711. // Ignore white space
  2712. while (($formula{$index} == "\n") || ($formula{$index} == "\r")) {
  2713. ++$index;
  2714. }
  2715. if ($formula{$index} == ' ') {
  2716. while ($formula{$index} == ' ') {
  2717. ++$index;
  2718. }
  2719. // If we're expecting an operator, but only have a space between the previous and next operands (and both are
  2720. // Cell References) then we have an INTERSECTION operator
  2721. // echo 'Possible Intersect Operator<br />';
  2722. if (($expectingOperator) && (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'.*/i', substr($formula, $index), $match)) &&
  2723. ($output[count($output)-1]['type'] == 'Cell Reference')) {
  2724. // echo 'Element is an Intersect Operator<br />';
  2725. while($stack->count() > 0 &&
  2726. ($o2 = $stack->last()) &&
  2727. in_array($o2['value'], self::$_operators) &&
  2728. @($operatorAssociativity[$opCharacter] ? $operatorPrecedence[$opCharacter] < $operatorPrecedence[$o2['value']] : $operatorPrecedence[$opCharacter] <= $operatorPrecedence[$o2['value']])) {
  2729. $output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output
  2730. }
  2731. $stack->push('Binary Operator','|'); // Put an Intersect Operator on the stack
  2732. $expectingOperator = false;
  2733. }
  2734. }
  2735. }
  2736. while (!is_null($op = $stack->pop())) { // pop everything off the stack and push onto output
  2737. if ($opCharacter['value'] == '(') return $this->_raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced
  2738. $output[] = $op;
  2739. }
  2740. return $output;
  2741. } // function _parseFormula()
  2742. // evaluate postfix notation
  2743. private function _processTokenStack($tokens, $cellID = null, PHPExcel_Cell $pCell = null) {
  2744. if ($tokens == false) return false;
  2745. // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet),
  2746. // so we store the parent worksheet so that we can re-attach it when necessary
  2747. $pCellParent = (!is_null($pCell)) ? $pCell->getParent() : null;
  2748. $stack = new PHPExcel_Token_Stack;
  2749. // Loop through each token in turn
  2750. foreach ($tokens as $tokenData) {
  2751. // print_r($tokenData);
  2752. // echo '<br />';
  2753. $token = $tokenData['value'];
  2754. // echo '<b>Token is '.$token.'</b><br />';
  2755. // 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
  2756. if (in_array($token, self::$_binaryOperators, true)) {
  2757. // echo 'Token is a binary operator<br />';
  2758. // We must have two operands, error if we don't
  2759. if (is_null($operand2Data = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
  2760. if (is_null($operand1Data = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
  2761. // Log what we're doing
  2762. $operand1 = $operand1Data['value'];
  2763. $operand2 = $operand2Data['value'];
  2764. if ($token == ':') {
  2765. $this->_writeDebug('Evaluating Range '.self::_showValue($operand1Data['reference']).$token.self::_showValue($operand2Data['reference']));
  2766. } else {
  2767. $this->_writeDebug('Evaluating '.self::_showValue($operand1).' '.$token.' '.self::_showValue($operand2));
  2768. }
  2769. // Process the operation in the appropriate manner
  2770. switch ($token) {
  2771. // Comparison (Boolean) Operators
  2772. case '>' : // Greater than
  2773. case '<' : // Less than
  2774. case '>=' : // Greater than or Equal to
  2775. case '<=' : // Less than or Equal to
  2776. case '=' : // Equality
  2777. case '<>' : // Inequality
  2778. $this->_executeBinaryComparisonOperation($cellID,$operand1,$operand2,$token,$stack);
  2779. break;
  2780. // Binary Operators
  2781. case ':' : // Range
  2782. $sheet1 = $sheet2 = '';
  2783. if (strpos($operand1Data['reference'],'!') !== false) {
  2784. list($sheet1,$operand1Data['reference']) = explode('!',$operand1Data['reference']);
  2785. } else {
  2786. $sheet1 = (!is_null($pCellParent)) ? $pCellParent->getTitle() : '';
  2787. }
  2788. if (strpos($operand2Data['reference'],'!') !== false) {
  2789. list($sheet2,$operand2Data['reference']) = explode('!',$operand2Data['reference']);
  2790. } else {
  2791. $sheet2 = $sheet1;
  2792. }
  2793. if ($sheet1 == $sheet2) {
  2794. if (is_null($operand1Data['reference'])) {
  2795. if ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) {
  2796. $operand1Data['reference'] = $pCell->getColumn().$operand1Data['value'];
  2797. } elseif (trim($operand1Data['reference']) == '') {
  2798. $operand1Data['reference'] = $pCell->getColumn().$pCell->getRow();
  2799. } else {
  2800. $operand1Data['reference'] = $operand1Data['value'].$pCell->getRow();
  2801. }
  2802. }
  2803. if (is_null($operand2Data['reference'])) {
  2804. if ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) {
  2805. $operand2Data['reference'] = $pCell->getColumn().$operand2Data['value'];
  2806. } elseif (trim($operand2Data['reference']) == '') {
  2807. $operand2Data['reference'] = $pCell->getColumn().$pCell->getRow();
  2808. } else {
  2809. $operand2Data['reference'] = $operand2Data['value'].$pCell->getRow();
  2810. }
  2811. }
  2812. $oData = array_merge(explode(':',$operand1Data['reference']),explode(':',$operand2Data['reference']));
  2813. $oCol = $oRow = array();
  2814. foreach($oData as $oDatum) {
  2815. $oCR = PHPExcel_Cell::coordinateFromString($oDatum);
  2816. $oCol[] = PHPExcel_Cell::columnIndexFromString($oCR[0]) - 1;
  2817. $oRow[] = $oCR[1];
  2818. }
  2819. $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
  2820. if (!is_null($pCellParent)) {
  2821. $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($sheet1), false);
  2822. } else {
  2823. return $this->_raiseFormulaError('Unable to access Cell Reference');
  2824. }
  2825. $stack->push('Cell Reference',$cellValue,$cellRef);
  2826. } else {
  2827. $stack->push('Error',PHPExcel_Calculation_Functions::REF(),NULL);
  2828. }
  2829. break;
  2830. case '+' : // Addition
  2831. $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'plusEquals',$stack);
  2832. break;
  2833. case '-' : // Subtraction
  2834. $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'minusEquals',$stack);
  2835. break;
  2836. case '*' : // Multiplication
  2837. $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayTimesEquals',$stack);
  2838. break;
  2839. case '/' : // Division
  2840. $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'arrayRightDivide',$stack);
  2841. break;
  2842. case '^' : // Exponential
  2843. $this->_executeNumericBinaryOperation($cellID,$operand1,$operand2,$token,'power',$stack);
  2844. break;
  2845. case '&' : // Concatenation
  2846. // If either of the operands is a matrix, we need to treat them both as matrices
  2847. // (converting the other operand to a matrix if need be); then perform the required
  2848. // matrix operation
  2849. if (is_bool($operand1)) {
  2850. $operand1 = ($operand1) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
  2851. }
  2852. if (is_bool($operand2)) {
  2853. $operand2 = ($operand2) ? self::$_localeBoolean['TRUE'] : self::$_localeBoolean['FALSE'];
  2854. }
  2855. if ((is_array($operand1)) || (is_array($operand2))) {
  2856. // Ensure that both operands are arrays/matrices
  2857. self::_checkMatrixOperands($operand1,$operand2,2);
  2858. try {
  2859. // Convert operand 1 from a PHP array to a matrix
  2860. $matrix = new Matrix($operand1);
  2861. // Perform the required operation against the operand 1 matrix, passing in operand 2
  2862. $matrixResult = $matrix->concat($operand2);
  2863. $result = $matrixResult->getArray();
  2864. } catch (Exception $ex) {
  2865. $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage());
  2866. $result = '#VALUE!';
  2867. }
  2868. } else {
  2869. $result = '"'.str_replace('""','"',self::_unwrapResult($operand1,'"').self::_unwrapResult($operand2,'"')).'"';
  2870. }
  2871. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
  2872. $stack->push('Value',$result);
  2873. break;
  2874. case '|' : // Intersect
  2875. $rowIntersect = array_intersect_key($operand1,$operand2);
  2876. $cellIntersect = $oCol = $oRow = array();
  2877. foreach(array_keys($rowIntersect) as $col) {
  2878. $oCol[] = PHPExcel_Cell::columnIndexFromString($col) - 1;
  2879. $cellIntersect[$col] = array_intersect_key($operand1[$col],$operand2[$col]);
  2880. foreach($cellIntersect[$col] as $row => $data) {
  2881. $oRow[] = $row;
  2882. }
  2883. }
  2884. $cellRef = PHPExcel_Cell::stringFromColumnIndex(min($oCol)).min($oRow).':'.PHPExcel_Cell::stringFromColumnIndex(max($oCol)).max($oRow);
  2885. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($cellIntersect));
  2886. $stack->push('Value',$cellIntersect,$cellRef);
  2887. break;
  2888. }
  2889. // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on
  2890. } elseif (($token === '~') || ($token === '%')) {
  2891. // echo 'Token is a unary operator<br />';
  2892. if (is_null($arg = $stack->pop())) return $this->_raiseFormulaError('Internal error - Operand value missing from stack');
  2893. $arg = $arg['value'];
  2894. if ($token === '~') {
  2895. // echo 'Token is a negation operator<br />';
  2896. $this->_writeDebug('Evaluating Negation of '.self::_showValue($arg));
  2897. $multiplier = -1;
  2898. } else {
  2899. // echo 'Token is a percentile operator<br />';
  2900. $this->_writeDebug('Evaluating Percentile of '.self::_showValue($arg));
  2901. $multiplier = 0.01;
  2902. }
  2903. if (is_array($arg)) {
  2904. self::_checkMatrixOperands($arg,$multiplier,2);
  2905. try {
  2906. $matrix1 = new Matrix($arg);
  2907. $matrixResult = $matrix1->arrayTimesEquals($multiplier);
  2908. $result = $matrixResult->getArray();
  2909. } catch (Exception $ex) {
  2910. $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage());
  2911. $result = '#VALUE!';
  2912. }
  2913. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
  2914. $stack->push('Value',$result);
  2915. } else {
  2916. $this->_executeNumericBinaryOperation($cellID,$multiplier,$arg,'*','arrayTimesEquals',$stack);
  2917. }
  2918. } elseif (preg_match('/^'.self::CALCULATION_REGEXP_CELLREF.'$/i', $token, $matches)) {
  2919. $cellRef = null;
  2920. // echo 'Element '.$token.' is a Cell reference<br />';
  2921. if (isset($matches[8])) {
  2922. // echo 'Reference is a Range of cells<br />';
  2923. if (is_null($pCell)) {
  2924. // We can't access the range, so return a REF error
  2925. $cellValue = PHPExcel_Calculation_Functions::REF();
  2926. } else {
  2927. $cellRef = $matches[6].$matches[7].':'.$matches[9].$matches[10];
  2928. if ($matches[2] > '') {
  2929. $matches[2] = trim($matches[2],"\"'");
  2930. // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
  2931. $this->_writeDebug('Evaluating Cell Range '.$cellRef.' in worksheet '.$matches[2]);
  2932. if (!is_null($pCellParent)) {
  2933. $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
  2934. } else {
  2935. return $this->_raiseFormulaError('Unable to access Cell Reference');
  2936. }
  2937. $this->_writeDebug('Evaluation Result for cells '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
  2938. // $cellRef = $matches[2].'!'.$cellRef;
  2939. } else {
  2940. // echo '$cellRef='.$cellRef.' in current worksheet<br />';
  2941. $this->_writeDebug('Evaluating Cell Range '.$cellRef.' in current worksheet');
  2942. if (!is_null($pCellParent)) {
  2943. $cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
  2944. } else {
  2945. return $this->_raiseFormulaError('Unable to access Cell Reference');
  2946. }
  2947. $this->_writeDebug('Evaluation Result for cells '.$cellRef.' is '.self::_showTypeDetails($cellValue));
  2948. }
  2949. }
  2950. } else {
  2951. // echo 'Reference is a single Cell<br />';
  2952. if (is_null($pCell)) {
  2953. // We can't access the cell, so return a REF error
  2954. $cellValue = PHPExcel_Calculation_Functions::REF();
  2955. } else {
  2956. $cellRef = $matches[6].$matches[7];
  2957. if ($matches[2] > '') {
  2958. $matches[2] = trim($matches[2],"\"'");
  2959. // echo '$cellRef='.$cellRef.' in worksheet '.$matches[2].'<br />';
  2960. $this->_writeDebug('Evaluating Cell '.$cellRef.' in worksheet '.$matches[2]);
  2961. if (!is_null($pCellParent)) {
  2962. if ($pCellParent->getParent()->getSheetByName($matches[2])->cellExists($cellRef)) {
  2963. $cellValue = $this->extractCellRange($cellRef, $pCellParent->getParent()->getSheetByName($matches[2]), false);
  2964. $pCell->attach($pCellParent);
  2965. } else {
  2966. $cellValue = PHPExcel_Calculation_Functions::REF();
  2967. }
  2968. } else {
  2969. return $this->_raiseFormulaError('Unable to access Cell Reference');
  2970. }
  2971. $this->_writeDebug('Evaluation Result for cell '.$cellRef.' in worksheet '.$matches[2].' is '.self::_showTypeDetails($cellValue));
  2972. // $cellRef = $matches[2].'!'.$cellRef;
  2973. } else {
  2974. // echo '$cellRef='.$cellRef.' in current worksheet<br />';
  2975. $this->_writeDebug('Evaluating Cell '.$cellRef.' in current worksheet');
  2976. if ($pCellParent->cellExists($cellRef)) {
  2977. $cellValue = $this->extractCellRange($cellRef, $pCellParent, false);
  2978. $pCell->attach($pCellParent);
  2979. } else {
  2980. $cellValue = NULL;
  2981. }
  2982. $this->_writeDebug('Evaluation Result for cell '.$cellRef.' is '.self::_showTypeDetails($cellValue));
  2983. }
  2984. }
  2985. }
  2986. $stack->push('Value',$cellValue,$cellRef);
  2987. // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on
  2988. } elseif (preg_match('/^'.self::CALCULATION_REGEXP_FUNCTION.'$/i', $token, $matches)) {
  2989. // echo 'Token is a function<br />';
  2990. $functionName = $matches[1];
  2991. $argCount = $stack->pop();
  2992. $argCount = $argCount['value'];
  2993. if ($functionName != 'MKMATRIX') {
  2994. $this->_writeDebug('Evaluating Function '.self::_localeFunc($functionName).'() with '.(($argCount == 0) ? 'no' : $argCount).' argument'.(($argCount == 1) ? '' : 's'));
  2995. }
  2996. if ((array_key_exists($functionName, self::$_PHPExcelFunctions)) || (array_key_exists($functionName, self::$_controlFunctions))) { // function
  2997. if (array_key_exists($functionName, self::$_PHPExcelFunctions)) {
  2998. $functionCall = self::$_PHPExcelFunctions[$functionName]['functionCall'];
  2999. $passByReference = isset(self::$_PHPExcelFunctions[$functionName]['passByReference']);
  3000. $passCellReference = isset(self::$_PHPExcelFunctions[$functionName]['passCellReference']);
  3001. } elseif (array_key_exists($functionName, self::$_controlFunctions)) {
  3002. $functionCall = self::$_controlFunctions[$functionName]['functionCall'];
  3003. $passByReference = isset(self::$_controlFunctions[$functionName]['passByReference']);
  3004. $passCellReference = isset(self::$_controlFunctions[$functionName]['passCellReference']);
  3005. }
  3006. // get the arguments for this function
  3007. // echo 'Function '.$functionName.' expects '.$argCount.' arguments<br />';
  3008. $args = $argArrayVals = array();
  3009. for ($i = 0; $i < $argCount; ++$i) {
  3010. $arg = $stack->pop();
  3011. $a = $argCount - $i - 1;
  3012. if (($passByReference) &&
  3013. (isset(self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) &&
  3014. (self::$_PHPExcelFunctions[$functionName]['passByReference'][$a])) {
  3015. if (is_null($arg['reference'])) {
  3016. $args[] = $cellID;
  3017. if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($cellID); }
  3018. } else {
  3019. $args[] = $arg['reference'];
  3020. if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($arg['reference']); }
  3021. }
  3022. } else {
  3023. $args[] = self::_unwrapResult($arg['value']);
  3024. if ($functionName != 'MKMATRIX') { $argArrayVals[] = self::_showValue($arg['value']); }
  3025. }
  3026. }
  3027. // Reverse the order of the arguments
  3028. krsort($args);
  3029. if (($passByReference) && ($argCount == 0)) {
  3030. $args[] = $cellID;
  3031. $argArrayVals[] = self::_showValue($cellID);
  3032. }
  3033. // echo 'Arguments are: ';
  3034. // print_r($args);
  3035. // echo '<br />';
  3036. if ($functionName != 'MKMATRIX') {
  3037. krsort($argArrayVals);
  3038. $this->_writeDebug('Evaluating '. self::_localeFunc($functionName).'( '.implode(self::$_localeArgumentSeparator.' ',$argArrayVals).' )');
  3039. }
  3040. // Process each argument in turn, building the return value as an array
  3041. // if (($argCount == 1) && (is_array($args[1])) && ($functionName != 'MKMATRIX')) {
  3042. // $operand1 = $args[1];
  3043. // $this->_writeDebug('Argument is a matrix: '.self::_showValue($operand1));
  3044. // $result = array();
  3045. // $row = 0;
  3046. // foreach($operand1 as $args) {
  3047. // if (is_array($args)) {
  3048. // foreach($args as $arg) {
  3049. // $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($arg).' )');
  3050. // $r = call_user_func_array($functionCall,$arg);
  3051. // $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
  3052. // $result[$row][] = $r;
  3053. // }
  3054. // ++$row;
  3055. // } else {
  3056. // $this->_writeDebug('Evaluating '.self::_localeFunc($functionName).'( '.self::_showValue($args).' )');
  3057. // $r = call_user_func_array($functionCall,$args);
  3058. // $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($r));
  3059. // $result[] = $r;
  3060. // }
  3061. // }
  3062. // } else {
  3063. // Process the argument with the appropriate function call
  3064. if ($passCellReference) {
  3065. $args[] = $pCell;
  3066. }
  3067. if (strpos($functionCall,'::') !== false) {
  3068. $result = call_user_func_array(explode('::',$functionCall),$args);
  3069. } else {
  3070. foreach($args as &$arg) {
  3071. $arg = PHPExcel_Calculation_Functions::flattenSingleValue($arg);
  3072. }
  3073. unset($arg);
  3074. $result = call_user_func_array($functionCall,$args);
  3075. }
  3076. // }
  3077. if ($functionName != 'MKMATRIX') {
  3078. $this->_writeDebug('Evaluation Result for '.self::_localeFunc($functionName).'() function call is '.self::_showTypeDetails($result));
  3079. }
  3080. $stack->push('Value',self::_wrapResult($result));
  3081. }
  3082. } else {
  3083. // if the token is a number, boolean, string or an Excel error, push it onto the stack
  3084. if (array_key_exists(strtoupper($token), self::$_ExcelConstants)) {
  3085. $excelConstant = strtoupper($token);
  3086. // echo 'Token is a PHPExcel constant: '.$excelConstant.'<br />';
  3087. $stack->push('Constant Value',self::$_ExcelConstants[$excelConstant]);
  3088. $this->_writeDebug('Evaluating Constant '.$excelConstant.' as '.self::_showTypeDetails(self::$_ExcelConstants[$excelConstant]));
  3089. } elseif ((is_numeric($token)) || (is_bool($token)) || (is_null($token)) || ($token == '') || ($token{0} == '"') || ($token{0} == '#')) {
  3090. // echo 'Token is a number, boolean, string, null or an Excel error<br />';
  3091. $stack->push('Value',$token);
  3092. // if the token is a named range, push the named range name onto the stack
  3093. } elseif (preg_match('/^'.self::CALCULATION_REGEXP_NAMEDRANGE.'$/i', $token, $matches)) {
  3094. // echo 'Token is a named range<br />';
  3095. $namedRange = $matches[6];
  3096. // echo 'Named Range is '.$namedRange.'<br />';
  3097. $this->_writeDebug('Evaluating Named Range '.$namedRange);
  3098. $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellParent : null), false);
  3099. $pCell->attach($pCellParent);
  3100. $this->_writeDebug('Evaluation Result for named range '.$namedRange.' is '.self::_showTypeDetails($cellValue));
  3101. $stack->push('Named Range',$cellValue,$namedRange);
  3102. } else {
  3103. return $this->_raiseFormulaError("undefined variable '$token'");
  3104. }
  3105. }
  3106. }
  3107. // when we're out of tokens, the stack should have a single element, the final result
  3108. if ($stack->count() != 1) return $this->_raiseFormulaError("internal error");
  3109. $output = $stack->pop();
  3110. $output = $output['value'];
  3111. // if ((is_array($output)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) {
  3112. // return array_shift(PHPExcel_Calculation_Functions::flattenArray($output));
  3113. // }
  3114. return $output;
  3115. } // function _processTokenStack()
  3116. private function _validateBinaryOperand($cellID,&$operand,&$stack) {
  3117. // Numbers, matrices and booleans can pass straight through, as they're already valid
  3118. if (is_string($operand)) {
  3119. // We only need special validations for the operand if it is a string
  3120. // Start by stripping off the quotation marks we use to identify true excel string values internally
  3121. if ($operand > '' && $operand{0} == '"') { $operand = self::_unwrapResult($operand); }
  3122. // If the string is a numeric value, we treat it as a numeric, so no further testing
  3123. if (!is_numeric($operand)) {
  3124. // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations
  3125. if ($operand > '' && $operand{0} == '#') {
  3126. $stack->push('Value', $operand);
  3127. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($operand));
  3128. return false;
  3129. } elseif (!PHPExcel_Shared_String::convertToNumberIfFraction($operand)) {
  3130. // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations
  3131. $stack->push('Value', '#VALUE!');
  3132. $this->_writeDebug('Evaluation Result is a '.self::_showTypeDetails('#VALUE!'));
  3133. return false;
  3134. }
  3135. }
  3136. }
  3137. // return a true if the value of the operand is one that we can use in normal binary operations
  3138. return true;
  3139. } // function _validateBinaryOperand()
  3140. private function _executeBinaryComparisonOperation($cellID,$operand1,$operand2,$operation,&$stack,$recursingArrays=false) {
  3141. // If we're dealing with matrix operations, we want a matrix result
  3142. if ((is_array($operand1)) || (is_array($operand2))) {
  3143. $result = array();
  3144. if ((is_array($operand1)) && (!is_array($operand2))) {
  3145. foreach($operand1 as $x => $operandData) {
  3146. $this->_writeDebug('Evaluating '.self::_showValue($operandData).' '.$operation.' '.self::_showValue($operand2));
  3147. $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2,$operation,$stack);
  3148. $r = $stack->pop();
  3149. $result[$x] = $r['value'];
  3150. }
  3151. } elseif ((!is_array($operand1)) && (is_array($operand2))) {
  3152. foreach($operand2 as $x => $operandData) {
  3153. $this->_writeDebug('Evaluating '.self::_showValue($operand1).' '.$operation.' '.self::_showValue($operandData));
  3154. $this->_executeBinaryComparisonOperation($cellID,$operand1,$operandData,$operation,$stack);
  3155. $r = $stack->pop();
  3156. $result[$x] = $r['value'];
  3157. }
  3158. } else {
  3159. if (!$recursingArrays) { self::_checkMatrixOperands($operand1,$operand2,2); }
  3160. foreach($operand1 as $x => $operandData) {
  3161. $this->_writeDebug('Evaluating '.self::_showValue($operandData).' '.$operation.' '.self::_showValue($operand2[$x]));
  3162. $this->_executeBinaryComparisonOperation($cellID,$operandData,$operand2[$x],$operation,$stack,True);
  3163. $r = $stack->pop();
  3164. $result[$x] = $r['value'];
  3165. }
  3166. }
  3167. // Log the result details
  3168. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
  3169. // And push the result onto the stack
  3170. $stack->push('Array',$result);
  3171. return true;
  3172. }
  3173. // Simple validate the two operands if they are string values
  3174. if (is_string($operand1) && $operand1 > '' && $operand1{0} == '"') { $operand1 = self::_unwrapResult($operand1); }
  3175. if (is_string($operand2) && $operand2 > '' && $operand2{0} == '"') { $operand2 = self::_unwrapResult($operand2); }
  3176. // execute the necessary operation
  3177. switch ($operation) {
  3178. // Greater than
  3179. case '>':
  3180. $result = ($operand1 > $operand2);
  3181. break;
  3182. // Less than
  3183. case '<':
  3184. $result = ($operand1 < $operand2);
  3185. break;
  3186. // Equality
  3187. case '=':
  3188. $result = ($operand1 == $operand2);
  3189. break;
  3190. // Greater than or equal
  3191. case '>=':
  3192. $result = ($operand1 >= $operand2);
  3193. break;
  3194. // Less than or equal
  3195. case '<=':
  3196. $result = ($operand1 <= $operand2);
  3197. break;
  3198. // Inequality
  3199. case '<>':
  3200. $result = ($operand1 != $operand2);
  3201. break;
  3202. }
  3203. // Log the result details
  3204. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
  3205. // And push the result onto the stack
  3206. $stack->push('Value',$result);
  3207. return true;
  3208. } // function _executeBinaryComparisonOperation()
  3209. private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$operation,$matrixFunction,&$stack) {
  3210. // Validate the two operands
  3211. if (!$this->_validateBinaryOperand($cellID,$operand1,$stack)) return false;
  3212. if (!$this->_validateBinaryOperand($cellID,$operand2,$stack)) return false;
  3213. // If either of the operands is a matrix, we need to treat them both as matrices
  3214. // (converting the other operand to a matrix if need be); then perform the required
  3215. // matrix operation
  3216. if ((is_array($operand1)) || (is_array($operand2))) {
  3217. // Ensure that both operands are arrays/matrices
  3218. self::_checkMatrixOperands($operand1,$operand2,2);
  3219. try {
  3220. // Convert operand 1 from a PHP array to a matrix
  3221. $matrix = new Matrix($operand1);
  3222. // Perform the required operation against the operand 1 matrix, passing in operand 2
  3223. $matrixResult = $matrix->$matrixFunction($operand2);
  3224. $result = $matrixResult->getArray();
  3225. } catch (Exception $ex) {
  3226. $this->_writeDebug('JAMA Matrix Exception: '.$ex->getMessage());
  3227. $result = '#VALUE!';
  3228. }
  3229. } else {
  3230. // If we're dealing with non-matrix operations, execute the necessary operation
  3231. switch ($operation) {
  3232. // Addition
  3233. case '+':
  3234. $result = $operand1+$operand2;
  3235. break;
  3236. // Subtraction
  3237. case '-':
  3238. $result = $operand1-$operand2;
  3239. break;
  3240. // Multiplication
  3241. case '*':
  3242. $result = $operand1*$operand2;
  3243. break;
  3244. // Division
  3245. case '/':
  3246. if ($operand2 == 0) {
  3247. // Trap for Divide by Zero error
  3248. $stack->push('Value','#DIV/0!');
  3249. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails('#DIV/0!'));
  3250. return false;
  3251. } else {
  3252. $result = $operand1/$operand2;
  3253. }
  3254. break;
  3255. // Power
  3256. case '^':
  3257. $result = pow($operand1,$operand2);
  3258. break;
  3259. }
  3260. }
  3261. // Log the result details
  3262. $this->_writeDebug('Evaluation Result is '.self::_showTypeDetails($result));
  3263. // And push the result onto the stack
  3264. $stack->push('Value',$result);
  3265. return true;
  3266. } // function _executeNumericBinaryOperation()
  3267. private function _writeDebug($message) {
  3268. // Only write the debug log if logging is enabled
  3269. if ($this->writeDebugLog) {
  3270. $this->debugLog[] = implode(' -> ',$this->debugLogStack).' -> '.$message;
  3271. }
  3272. } // function _writeDebug()
  3273. // trigger an error, but nicely, if need be
  3274. protected function _raiseFormulaError($errorMessage) {
  3275. $this->formulaError = $errorMessage;
  3276. if (!$this->suppressFormulaErrors) throw new Exception($errorMessage);
  3277. trigger_error($errorMessage, E_USER_ERROR);
  3278. } // function _raiseFormulaError()
  3279. /**
  3280. * Extract range values
  3281. *
  3282. * @param string &$pRange String based range representation
  3283. * @param PHPExcel_Worksheet $pSheet Worksheet
  3284. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  3285. * @throws Exception
  3286. */
  3287. public function extractCellRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) {
  3288. // Return value
  3289. $returnValue = array ();
  3290. // echo 'extractCellRange('.$pRange.')<br />';
  3291. if (!is_null($pSheet)) {
  3292. // echo 'Passed sheet name is '.$pSheet->getTitle().'<br />';
  3293. // echo 'Range reference is '.$pRange.'<br />';
  3294. if (strpos ($pRange, '!') !== false) {
  3295. // echo '$pRange reference includes sheet reference<br />';
  3296. $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
  3297. $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
  3298. // echo 'New sheet name is '.$pSheet->getTitle().'<br />';
  3299. $pRange = $worksheetReference[1];
  3300. // echo 'Adjusted Range reference is '.$pRange.'<br />';
  3301. }
  3302. // Extract range
  3303. $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
  3304. $pRange = $pSheet->getTitle().'!'.$pRange;
  3305. if (count($aReferences) == 1) {
  3306. list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
  3307. if ($pSheet->cellExists($aReferences[0])) {
  3308. $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
  3309. } else {
  3310. $returnValue[$currentRow][$currentCol] = NULL;
  3311. }
  3312. } else {
  3313. // Extract cell data
  3314. foreach ($aReferences as $reference) {
  3315. // Extract range
  3316. list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
  3317. if ($pSheet->cellExists($reference)) {
  3318. $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
  3319. } else {
  3320. $returnValue[$currentRow][$currentCol] = NULL;
  3321. }
  3322. }
  3323. }
  3324. }
  3325. // Return
  3326. return $returnValue;
  3327. } // function extractCellRange()
  3328. /**
  3329. * Extract range values
  3330. *
  3331. * @param string &$pRange String based range representation
  3332. * @param PHPExcel_Worksheet $pSheet Worksheet
  3333. * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned.
  3334. * @throws Exception
  3335. */
  3336. public function extractNamedRange(&$pRange = 'A1', PHPExcel_Worksheet $pSheet = null, $resetLog=true) {
  3337. // Return value
  3338. $returnValue = array ();
  3339. // echo 'extractNamedRange('.$pRange.')<br />';
  3340. if (!is_null($pSheet)) {
  3341. // echo 'Current sheet name is '.$pSheet->getTitle().'<br />';
  3342. // echo 'Range reference is '.$pRange.'<br />';
  3343. if (strpos ($pRange, '!') !== false) {
  3344. // echo '$pRange reference includes sheet reference<br />';
  3345. $worksheetReference = PHPExcel_Worksheet::extractSheetTitle($pRange, true);
  3346. $pSheet = $pSheet->getParent()->getSheetByName($worksheetReference[0]);
  3347. // echo 'New sheet name is '.$pSheet->getTitle().'<br />';
  3348. $pRange = $worksheetReference[1];
  3349. // echo 'Adjusted Range reference is '.$pRange.'<br />';
  3350. }
  3351. // Named range?
  3352. $namedRange = PHPExcel_NamedRange::resolveRange($pRange, $pSheet);
  3353. if (!is_null($namedRange)) {
  3354. $pSheet = $namedRange->getWorksheet();
  3355. //// echo 'Named Range '.$pRange.' (';
  3356. $pRange = $namedRange->getRange();
  3357. //// echo $pRange.') is in sheet '.$namedRange->getWorksheet()->getTitle().'<br />';
  3358. // if ($pSheet->getTitle() != $namedRange->getWorksheet()->getTitle()) {
  3359. // if (!$namedRange->getLocalOnly()) {
  3360. // $pSheet = $namedRange->getWorksheet();
  3361. // } else {
  3362. // return $returnValue;
  3363. // }
  3364. // }
  3365. } else {
  3366. return PHPExcel_Calculation_Functions::REF();
  3367. }
  3368. // Extract range
  3369. $aReferences = PHPExcel_Cell::extractAllCellReferencesInRange($pRange);
  3370. if (count($aReferences) == 1) {
  3371. list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($aReferences[0]);
  3372. if ($pSheet->cellExists($aReferences[0])) {
  3373. $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);
  3374. } else {
  3375. $returnValue[$currentRow][$currentCol] = NULL;
  3376. }
  3377. } else {
  3378. // Extract cell data
  3379. foreach ($aReferences as $reference) {
  3380. // Extract range
  3381. list($currentCol,$currentRow) = PHPExcel_Cell::coordinateFromString($reference);
  3382. // echo 'NAMED RANGE: $currentCol='.$currentCol.' $currentRow='.$currentRow.'<br />';
  3383. if ($pSheet->cellExists($reference)) {
  3384. $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);
  3385. } else {
  3386. $returnValue[$currentRow][$currentCol] = NULL;
  3387. }
  3388. }
  3389. }
  3390. // print_r($returnValue);
  3391. // echo '<br />';
  3392. }
  3393. // Return
  3394. return $returnValue;
  3395. } // function extractNamedRange()
  3396. /**
  3397. * Is a specific function implemented?
  3398. *
  3399. * @param string $pFunction Function Name
  3400. * @return boolean
  3401. */
  3402. public function isImplemented($pFunction = '') {
  3403. $pFunction = strtoupper ($pFunction);
  3404. if (isset(self::$_PHPExcelFunctions[$pFunction])) {
  3405. return (self::$_PHPExcelFunctions[$pFunction]['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY');
  3406. } else {
  3407. return false;
  3408. }
  3409. } // function isImplemented()
  3410. /**
  3411. * Get a list of all implemented functions as an array of function objects
  3412. *
  3413. * @return array of PHPExcel_Calculation_Function
  3414. */
  3415. public function listFunctions() {
  3416. // Return value
  3417. $returnValue = array();
  3418. // Loop functions
  3419. foreach(self::$_PHPExcelFunctions as $functionName => $function) {
  3420. if ($function['functionCall'] != 'PHPExcel_Calculation_Functions::DUMMY') {
  3421. $returnValue[$functionName] = new PHPExcel_Calculation_Function($function['category'],
  3422. $functionName,
  3423. $function['functionCall']
  3424. );
  3425. }
  3426. }
  3427. // Return
  3428. return $returnValue;
  3429. } // function listFunctions()
  3430. /**
  3431. * Get a list of implemented Excel function names
  3432. *
  3433. * @return array
  3434. */
  3435. public function listFunctionNames() {
  3436. return array_keys(self::$_PHPExcelFunctions);
  3437. } // function listFunctionNames()
  3438. } // class PHPExcel_Calculation
  3439. // for internal use
  3440. class PHPExcel_Token_Stack {
  3441. private $_stack = array();
  3442. private $_count = 0;
  3443. public function count() {
  3444. return $this->_count;
  3445. } // function count()
  3446. public function push($type,$value,$reference=null) {
  3447. $this->_stack[$this->_count++] = array('type' => $type,
  3448. 'value' => $value,
  3449. 'reference' => $reference
  3450. );
  3451. if ($type == 'Function') {
  3452. $localeFunction = PHPExcel_Calculation::_localeFunc($value);
  3453. if ($localeFunction != $value) {
  3454. $this->_stack[($this->_count - 1)]['localeValue'] = $localeFunction;
  3455. }
  3456. }
  3457. } // function push()
  3458. public function pop() {
  3459. if ($this->_count > 0) {
  3460. return $this->_stack[--$this->_count];
  3461. }
  3462. return null;
  3463. } // function pop()
  3464. public function last($n=1) {
  3465. if ($this->_count-$n < 0) {
  3466. return null;
  3467. }
  3468. return $this->_stack[$this->_count-$n];
  3469. } // function last()
  3470. function __construct() {
  3471. }
  3472. } // class PHPExcel_Token_Stack