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

/reports/PAL2/PHPExcel-ADODB/system/PHPExcel/PHPExcel/Calculation.php

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