Database.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. if (!defined('PHPEXCEL_ROOT')) {
  8. /**
  9. * @ignore
  10. */
  11. define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
  12. require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
  13. }
  14. /**
  15. * PHPExcel_Calculation_Database
  16. *
  17. * Copyright (c) 2006 - 2015 PHPExcel
  18. *
  19. * This library is free software; you can redistribute it and/or
  20. * modify it under the terms of the GNU Lesser General Public
  21. * License as published by the Free Software Foundation; either
  22. * version 2.1 of the License, or (at your option) any later version.
  23. *
  24. * This library is distributed in the hope that it will be useful,
  25. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  27. * Lesser General Public License for more details.
  28. *
  29. * You should have received a copy of the GNU Lesser General Public
  30. * License along with this library; if not, write to the Free Software
  31. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  32. *
  33. * @category PHPExcel
  34. * @package PHPExcel_Calculation
  35. * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  36. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
  37. * @version ##VERSION##, ##DATE##
  38. */
  39. class PHPExcel_Calculation_Database
  40. {
  41. /**
  42. * fieldExtract
  43. *
  44. * Extracts the column ID to use for the data field.
  45. *
  46. * @access private
  47. * @param mixed[] $database The range of cells that makes up the list or database.
  48. * A database is a list of related data in which rows of related
  49. * information are records, and columns of data are fields. The
  50. * first row of the list contains labels for each column.
  51. * @param mixed $field Indicates which column is used in the function. Enter the
  52. * column label enclosed between double quotation marks, such as
  53. * "Age" or "Yield," or a number (without quotation marks) that
  54. * represents the position of the column within the list: 1 for
  55. * the first column, 2 for the second column, and so on.
  56. * @return string|NULL
  57. *
  58. */
  59. private static function fieldExtract($database, $field)
  60. {
  61. $field = strtoupper(PHPExcel_Calculation_Functions::flattenSingleValue($field));
  62. $fieldNames = array_map('strtoupper', array_shift($database));
  63. if (is_numeric($field)) {
  64. $keys = array_keys($fieldNames);
  65. return $keys[$field-1];
  66. }
  67. $key = array_search($field, $fieldNames);
  68. return ($key) ? $key : null;
  69. }
  70. /**
  71. * filter
  72. *
  73. * Parses the selection criteria, extracts the database rows that match those criteria, and
  74. * returns that subset of rows.
  75. *
  76. * @access private
  77. * @param mixed[] $database The range of cells that makes up the list or database.
  78. * A database is a list of related data in which rows of related
  79. * information are records, and columns of data are fields. The
  80. * first row of the list contains labels for each column.
  81. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  82. * You can use any range for the criteria argument, as long as it
  83. * includes at least one column label and at least one cell below
  84. * the column label in which you specify a condition for the
  85. * column.
  86. * @return array of mixed
  87. *
  88. */
  89. private static function filter($database, $criteria)
  90. {
  91. $fieldNames = array_shift($database);
  92. $criteriaNames = array_shift($criteria);
  93. // Convert the criteria into a set of AND/OR conditions with [:placeholders]
  94. $testConditions = $testValues = array();
  95. $testConditionsCount = 0;
  96. foreach ($criteriaNames as $key => $criteriaName) {
  97. $testCondition = array();
  98. $testConditionCount = 0;
  99. foreach ($criteria as $row => $criterion) {
  100. if ($criterion[$key] > '') {
  101. $testCondition[] = '[:'.$criteriaName.']'.PHPExcel_Calculation_Functions::ifCondition($criterion[$key]);
  102. $testConditionCount++;
  103. }
  104. }
  105. if ($testConditionCount > 1) {
  106. $testConditions[] = 'OR(' . implode(',', $testCondition) . ')';
  107. $testConditionsCount++;
  108. } elseif ($testConditionCount == 1) {
  109. $testConditions[] = $testCondition[0];
  110. $testConditionsCount++;
  111. }
  112. }
  113. if ($testConditionsCount > 1) {
  114. $testConditionSet = 'AND(' . implode(',', $testConditions) . ')';
  115. } elseif ($testConditionsCount == 1) {
  116. $testConditionSet = $testConditions[0];
  117. }
  118. // Loop through each row of the database
  119. foreach ($database as $dataRow => $dataValues) {
  120. // Substitute actual values from the database row for our [:placeholders]
  121. $testConditionList = $testConditionSet;
  122. foreach ($criteriaNames as $key => $criteriaName) {
  123. $k = array_search($criteriaName, $fieldNames);
  124. if (isset($dataValues[$k])) {
  125. $dataValue = $dataValues[$k];
  126. $dataValue = (is_string($dataValue)) ? PHPExcel_Calculation::wrapResult(strtoupper($dataValue)) : $dataValue;
  127. $testConditionList = str_replace('[:' . $criteriaName . ']', $dataValue, $testConditionList);
  128. }
  129. }
  130. // evaluate the criteria against the row data
  131. $result = PHPExcel_Calculation::getInstance()->_calculateFormulaValue('='.$testConditionList);
  132. // If the row failed to meet the criteria, remove it from the database
  133. if (!$result) {
  134. unset($database[$dataRow]);
  135. }
  136. }
  137. return $database;
  138. }
  139. private static function getFilteredColumn($database, $field, $criteria)
  140. {
  141. // reduce the database to a set of rows that match all the criteria
  142. $database = self::filter($database, $criteria);
  143. // extract an array of values for the requested column
  144. $colData = array();
  145. foreach ($database as $row) {
  146. $colData[] = $row[$field];
  147. }
  148. return $colData;
  149. }
  150. /**
  151. * DAVERAGE
  152. *
  153. * Averages the values in a column of a list or database that match conditions you specify.
  154. *
  155. * Excel Function:
  156. * DAVERAGE(database,field,criteria)
  157. *
  158. * @access public
  159. * @category Database Functions
  160. * @param mixed[] $database The range of cells that makes up the list or database.
  161. * A database is a list of related data in which rows of related
  162. * information are records, and columns of data are fields. The
  163. * first row of the list contains labels for each column.
  164. * @param string|integer $field Indicates which column is used in the function. Enter the
  165. * column label enclosed between double quotation marks, such as
  166. * "Age" or "Yield," or a number (without quotation marks) that
  167. * represents the position of the column within the list: 1 for
  168. * the first column, 2 for the second column, and so on.
  169. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  170. * You can use any range for the criteria argument, as long as it
  171. * includes at least one column label and at least one cell below
  172. * the column label in which you specify a condition for the
  173. * column.
  174. * @return float
  175. *
  176. */
  177. public static function DAVERAGE($database, $field, $criteria)
  178. {
  179. $field = self::fieldExtract($database, $field);
  180. if (is_null($field)) {
  181. return null;
  182. }
  183. // Return
  184. return PHPExcel_Calculation_Statistical::AVERAGE(
  185. self::getFilteredColumn($database, $field, $criteria)
  186. );
  187. }
  188. /**
  189. * DCOUNT
  190. *
  191. * Counts the cells that contain numbers in a column of a list or database that match conditions
  192. * that you specify.
  193. *
  194. * Excel Function:
  195. * DCOUNT(database,[field],criteria)
  196. *
  197. * Excel Function:
  198. * DAVERAGE(database,field,criteria)
  199. *
  200. * @access public
  201. * @category Database Functions
  202. * @param mixed[] $database The range of cells that makes up the list or database.
  203. * A database is a list of related data in which rows of related
  204. * information are records, and columns of data are fields. The
  205. * first row of the list contains labels for each column.
  206. * @param string|integer $field Indicates which column is used in the function. Enter the
  207. * column label enclosed between double quotation marks, such as
  208. * "Age" or "Yield," or a number (without quotation marks) that
  209. * represents the position of the column within the list: 1 for
  210. * the first column, 2 for the second column, and so on.
  211. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  212. * You can use any range for the criteria argument, as long as it
  213. * includes at least one column label and at least one cell below
  214. * the column label in which you specify a condition for the
  215. * column.
  216. * @return integer
  217. *
  218. * @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the
  219. * database that match the criteria.
  220. *
  221. */
  222. public static function DCOUNT($database, $field, $criteria)
  223. {
  224. $field = self::fieldExtract($database, $field);
  225. if (is_null($field)) {
  226. return null;
  227. }
  228. // Return
  229. return PHPExcel_Calculation_Statistical::COUNT(
  230. self::getFilteredColumn($database, $field, $criteria)
  231. );
  232. }
  233. /**
  234. * DCOUNTA
  235. *
  236. * Counts the nonblank cells in a column of a list or database that match conditions that you specify.
  237. *
  238. * Excel Function:
  239. * DCOUNTA(database,[field],criteria)
  240. *
  241. * @access public
  242. * @category Database Functions
  243. * @param mixed[] $database The range of cells that makes up the list or database.
  244. * A database is a list of related data in which rows of related
  245. * information are records, and columns of data are fields. The
  246. * first row of the list contains labels for each column.
  247. * @param string|integer $field Indicates which column is used in the function. Enter the
  248. * column label enclosed between double quotation marks, such as
  249. * "Age" or "Yield," or a number (without quotation marks) that
  250. * represents the position of the column within the list: 1 for
  251. * the first column, 2 for the second column, and so on.
  252. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  253. * You can use any range for the criteria argument, as long as it
  254. * includes at least one column label and at least one cell below
  255. * the column label in which you specify a condition for the
  256. * column.
  257. * @return integer
  258. *
  259. * @TODO The field argument is optional. If field is omitted, DCOUNTA counts all records in the
  260. * database that match the criteria.
  261. *
  262. */
  263. public static function DCOUNTA($database, $field, $criteria)
  264. {
  265. $field = self::fieldExtract($database, $field);
  266. if (is_null($field)) {
  267. return null;
  268. }
  269. // reduce the database to a set of rows that match all the criteria
  270. $database = self::filter($database, $criteria);
  271. // extract an array of values for the requested column
  272. $colData = array();
  273. foreach ($database as $row) {
  274. $colData[] = $row[$field];
  275. }
  276. // Return
  277. return PHPExcel_Calculation_Statistical::COUNTA(
  278. self::getFilteredColumn($database, $field, $criteria)
  279. );
  280. }
  281. /**
  282. * DGET
  283. *
  284. * Extracts a single value from a column of a list or database that matches conditions that you
  285. * specify.
  286. *
  287. * Excel Function:
  288. * DGET(database,field,criteria)
  289. *
  290. * @access public
  291. * @category Database Functions
  292. * @param mixed[] $database The range of cells that makes up the list or database.
  293. * A database is a list of related data in which rows of related
  294. * information are records, and columns of data are fields. The
  295. * first row of the list contains labels for each column.
  296. * @param string|integer $field Indicates which column is used in the function. Enter the
  297. * column label enclosed between double quotation marks, such as
  298. * "Age" or "Yield," or a number (without quotation marks) that
  299. * represents the position of the column within the list: 1 for
  300. * the first column, 2 for the second column, and so on.
  301. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  302. * You can use any range for the criteria argument, as long as it
  303. * includes at least one column label and at least one cell below
  304. * the column label in which you specify a condition for the
  305. * column.
  306. * @return mixed
  307. *
  308. */
  309. public static function DGET($database, $field, $criteria)
  310. {
  311. $field = self::fieldExtract($database, $field);
  312. if (is_null($field)) {
  313. return null;
  314. }
  315. // Return
  316. $colData = self::getFilteredColumn($database, $field, $criteria);
  317. if (count($colData) > 1) {
  318. return PHPExcel_Calculation_Functions::NaN();
  319. }
  320. return $colData[0];
  321. }
  322. /**
  323. * DMAX
  324. *
  325. * Returns the largest number in a column of a list or database that matches conditions you that
  326. * specify.
  327. *
  328. * Excel Function:
  329. * DMAX(database,field,criteria)
  330. *
  331. * @access public
  332. * @category Database Functions
  333. * @param mixed[] $database The range of cells that makes up the list or database.
  334. * A database is a list of related data in which rows of related
  335. * information are records, and columns of data are fields. The
  336. * first row of the list contains labels for each column.
  337. * @param string|integer $field Indicates which column is used in the function. Enter the
  338. * column label enclosed between double quotation marks, such as
  339. * "Age" or "Yield," or a number (without quotation marks) that
  340. * represents the position of the column within the list: 1 for
  341. * the first column, 2 for the second column, and so on.
  342. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  343. * You can use any range for the criteria argument, as long as it
  344. * includes at least one column label and at least one cell below
  345. * the column label in which you specify a condition for the
  346. * column.
  347. * @return float
  348. *
  349. */
  350. public static function DMAX($database, $field, $criteria)
  351. {
  352. $field = self::fieldExtract($database, $field);
  353. if (is_null($field)) {
  354. return null;
  355. }
  356. // Return
  357. return PHPExcel_Calculation_Statistical::MAX(
  358. self::getFilteredColumn($database, $field, $criteria)
  359. );
  360. }
  361. /**
  362. * DMIN
  363. *
  364. * Returns the smallest number in a column of a list or database that matches conditions you that
  365. * specify.
  366. *
  367. * Excel Function:
  368. * DMIN(database,field,criteria)
  369. *
  370. * @access public
  371. * @category Database Functions
  372. * @param mixed[] $database The range of cells that makes up the list or database.
  373. * A database is a list of related data in which rows of related
  374. * information are records, and columns of data are fields. The
  375. * first row of the list contains labels for each column.
  376. * @param string|integer $field Indicates which column is used in the function. Enter the
  377. * column label enclosed between double quotation marks, such as
  378. * "Age" or "Yield," or a number (without quotation marks) that
  379. * represents the position of the column within the list: 1 for
  380. * the first column, 2 for the second column, and so on.
  381. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  382. * You can use any range for the criteria argument, as long as it
  383. * includes at least one column label and at least one cell below
  384. * the column label in which you specify a condition for the
  385. * column.
  386. * @return float
  387. *
  388. */
  389. public static function DMIN($database, $field, $criteria)
  390. {
  391. $field = self::fieldExtract($database, $field);
  392. if (is_null($field)) {
  393. return null;
  394. }
  395. // Return
  396. return PHPExcel_Calculation_Statistical::MIN(
  397. self::getFilteredColumn($database, $field, $criteria)
  398. );
  399. }
  400. /**
  401. * DPRODUCT
  402. *
  403. * Multiplies the values in a column of a list or database that match conditions that you specify.
  404. *
  405. * Excel Function:
  406. * DPRODUCT(database,field,criteria)
  407. *
  408. * @access public
  409. * @category Database Functions
  410. * @param mixed[] $database The range of cells that makes up the list or database.
  411. * A database is a list of related data in which rows of related
  412. * information are records, and columns of data are fields. The
  413. * first row of the list contains labels for each column.
  414. * @param string|integer $field Indicates which column is used in the function. Enter the
  415. * column label enclosed between double quotation marks, such as
  416. * "Age" or "Yield," or a number (without quotation marks) that
  417. * represents the position of the column within the list: 1 for
  418. * the first column, 2 for the second column, and so on.
  419. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  420. * You can use any range for the criteria argument, as long as it
  421. * includes at least one column label and at least one cell below
  422. * the column label in which you specify a condition for the
  423. * column.
  424. * @return float
  425. *
  426. */
  427. public static function DPRODUCT($database, $field, $criteria)
  428. {
  429. $field = self::fieldExtract($database, $field);
  430. if (is_null($field)) {
  431. return null;
  432. }
  433. // Return
  434. return PHPExcel_Calculation_MathTrig::PRODUCT(
  435. self::getFilteredColumn($database, $field, $criteria)
  436. );
  437. }
  438. /**
  439. * DSTDEV
  440. *
  441. * Estimates the standard deviation of a population based on a sample by using the numbers in a
  442. * column of a list or database that match conditions that you specify.
  443. *
  444. * Excel Function:
  445. * DSTDEV(database,field,criteria)
  446. *
  447. * @access public
  448. * @category Database Functions
  449. * @param mixed[] $database The range of cells that makes up the list or database.
  450. * A database is a list of related data in which rows of related
  451. * information are records, and columns of data are fields. The
  452. * first row of the list contains labels for each column.
  453. * @param string|integer $field Indicates which column is used in the function. Enter the
  454. * column label enclosed between double quotation marks, such as
  455. * "Age" or "Yield," or a number (without quotation marks) that
  456. * represents the position of the column within the list: 1 for
  457. * the first column, 2 for the second column, and so on.
  458. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  459. * You can use any range for the criteria argument, as long as it
  460. * includes at least one column label and at least one cell below
  461. * the column label in which you specify a condition for the
  462. * column.
  463. * @return float
  464. *
  465. */
  466. public static function DSTDEV($database, $field, $criteria)
  467. {
  468. $field = self::fieldExtract($database, $field);
  469. if (is_null($field)) {
  470. return null;
  471. }
  472. // Return
  473. return PHPExcel_Calculation_Statistical::STDEV(
  474. self::getFilteredColumn($database, $field, $criteria)
  475. );
  476. }
  477. /**
  478. * DSTDEVP
  479. *
  480. * Calculates the standard deviation of a population based on the entire population by using the
  481. * numbers in a column of a list or database that match conditions that you specify.
  482. *
  483. * Excel Function:
  484. * DSTDEVP(database,field,criteria)
  485. *
  486. * @access public
  487. * @category Database Functions
  488. * @param mixed[] $database The range of cells that makes up the list or database.
  489. * A database is a list of related data in which rows of related
  490. * information are records, and columns of data are fields. The
  491. * first row of the list contains labels for each column.
  492. * @param string|integer $field Indicates which column is used in the function. Enter the
  493. * column label enclosed between double quotation marks, such as
  494. * "Age" or "Yield," or a number (without quotation marks) that
  495. * represents the position of the column within the list: 1 for
  496. * the first column, 2 for the second column, and so on.
  497. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  498. * You can use any range for the criteria argument, as long as it
  499. * includes at least one column label and at least one cell below
  500. * the column label in which you specify a condition for the
  501. * column.
  502. * @return float
  503. *
  504. */
  505. public static function DSTDEVP($database, $field, $criteria)
  506. {
  507. $field = self::fieldExtract($database, $field);
  508. if (is_null($field)) {
  509. return null;
  510. }
  511. // Return
  512. return PHPExcel_Calculation_Statistical::STDEVP(
  513. self::getFilteredColumn($database, $field, $criteria)
  514. );
  515. }
  516. /**
  517. * DSUM
  518. *
  519. * Adds the numbers in a column of a list or database that match conditions that you specify.
  520. *
  521. * Excel Function:
  522. * DSUM(database,field,criteria)
  523. *
  524. * @access public
  525. * @category Database Functions
  526. * @param mixed[] $database The range of cells that makes up the list or database.
  527. * A database is a list of related data in which rows of related
  528. * information are records, and columns of data are fields. The
  529. * first row of the list contains labels for each column.
  530. * @param string|integer $field Indicates which column is used in the function. Enter the
  531. * column label enclosed between double quotation marks, such as
  532. * "Age" or "Yield," or a number (without quotation marks) that
  533. * represents the position of the column within the list: 1 for
  534. * the first column, 2 for the second column, and so on.
  535. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  536. * You can use any range for the criteria argument, as long as it
  537. * includes at least one column label and at least one cell below
  538. * the column label in which you specify a condition for the
  539. * column.
  540. * @return float
  541. *
  542. */
  543. public static function DSUM($database, $field, $criteria)
  544. {
  545. $field = self::fieldExtract($database, $field);
  546. if (is_null($field)) {
  547. return null;
  548. }
  549. // Return
  550. return PHPExcel_Calculation_MathTrig::SUM(
  551. self::getFilteredColumn($database, $field, $criteria)
  552. );
  553. }
  554. /**
  555. * DVAR
  556. *
  557. * Estimates the variance of a population based on a sample by using the numbers in a column
  558. * of a list or database that match conditions that you specify.
  559. *
  560. * Excel Function:
  561. * DVAR(database,field,criteria)
  562. *
  563. * @access public
  564. * @category Database Functions
  565. * @param mixed[] $database The range of cells that makes up the list or database.
  566. * A database is a list of related data in which rows of related
  567. * information are records, and columns of data are fields. The
  568. * first row of the list contains labels for each column.
  569. * @param string|integer $field Indicates which column is used in the function. Enter the
  570. * column label enclosed between double quotation marks, such as
  571. * "Age" or "Yield," or a number (without quotation marks) that
  572. * represents the position of the column within the list: 1 for
  573. * the first column, 2 for the second column, and so on.
  574. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  575. * You can use any range for the criteria argument, as long as it
  576. * includes at least one column label and at least one cell below
  577. * the column label in which you specify a condition for the
  578. * column.
  579. * @return float
  580. *
  581. */
  582. public static function DVAR($database, $field, $criteria)
  583. {
  584. $field = self::fieldExtract($database, $field);
  585. if (is_null($field)) {
  586. return null;
  587. }
  588. // Return
  589. return PHPExcel_Calculation_Statistical::VARFunc(
  590. self::getFilteredColumn($database, $field, $criteria)
  591. );
  592. }
  593. /**
  594. * DVARP
  595. *
  596. * Calculates the variance of a population based on the entire population by using the numbers
  597. * in a column of a list or database that match conditions that you specify.
  598. *
  599. * Excel Function:
  600. * DVARP(database,field,criteria)
  601. *
  602. * @access public
  603. * @category Database Functions
  604. * @param mixed[] $database The range of cells that makes up the list or database.
  605. * A database is a list of related data in which rows of related
  606. * information are records, and columns of data are fields. The
  607. * first row of the list contains labels for each column.
  608. * @param string|integer $field Indicates which column is used in the function. Enter the
  609. * column label enclosed between double quotation marks, such as
  610. * "Age" or "Yield," or a number (without quotation marks) that
  611. * represents the position of the column within the list: 1 for
  612. * the first column, 2 for the second column, and so on.
  613. * @param mixed[] $criteria The range of cells that contains the conditions you specify.
  614. * You can use any range for the criteria argument, as long as it
  615. * includes at least one column label and at least one cell below
  616. * the column label in which you specify a condition for the
  617. * column.
  618. * @return float
  619. *
  620. */
  621. public static function DVARP($database, $field, $criteria)
  622. {
  623. $field = self::fieldExtract($database, $field);
  624. if (is_null($field)) {
  625. return null;
  626. }
  627. // Return
  628. return PHPExcel_Calculation_Statistical::VARP(
  629. self::getFilteredColumn($database, $field, $criteria)
  630. );
  631. }
  632. }