Feature: Work Item 2346 - Implement more Excel calculation functions

Implemented the DGET() Database function

git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@68576 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
Mark Baker 2011-02-13 17:19:00 +00:00
parent c5c816a9c6
commit 7425aa8460
3 changed files with 28 additions and 2 deletions

View File

@ -595,7 +595,7 @@ class PHPExcel_Calculation {
'argumentCount' => '1+'
),
'DGET' => array('category' => PHPExcel_Calculation_Function::CATEGORY_DATABASE,
'functionCall' => 'PHPExcel_Calculation_Functions::DUMMY',
'functionCall' => 'PHPExcel_Calculation_Database::DGET',
'argumentCount' => '3'
),
'DISC' => array('category' => PHPExcel_Calculation_Function::CATEGORY_FINANCIAL,

View File

@ -178,6 +178,32 @@ class PHPExcel_Calculation_Database {
return PHPExcel_Calculation_Statistical::COUNTA($colData);
} // function DCOUNTA()
/**
* DGET
*
*/
public static function DGET($database,$field,$criteria) {
$field = self::__fieldExtract($database,$field);
if (is_null($field)) {
return NULL;
}
// reduce the database to a set of rows that match all the criteria
$database = self::__filter($database,$criteria);
// extract an array of values for the requested column
$colData = array();
foreach($database as $row) {
$colData[] = $row[$field];
}
// Return
if (count($colData) > 1) {
return PHPExcel_Calculation_Functions::NaN();
}
return $colData[0];
} // function DGET()
/**
* DMAX
*

View File

@ -36,7 +36,7 @@ Fixed in SVN:
- Feature: (MBaker) Added support for cell comments in the OOCalc, Gnumeric and Excel2003XML Readers, and in the Excel5 Reader
- Feature: (MBaker) Improved toFormattedString() handling for Currency and Accounting formats to render currency symbols
- Feature: (MBaker) Work Item 2346 - Implement more Excel calculation functions
- Implemented the DAVERAGE(), DCOUNT(), DCOUNTA(), DMAX(), DMIN(), DPRODUCT(), DSTDEV(), DSTDEVP(), DSUM(), DVAR() and DVARP() Database functions
- Implemented the DAVERAGE(), DCOUNT(), DCOUNTA(), DGET(), DMAX(), DMIN(), DPRODUCT(), DSTDEV(), DSTDEVP(), DSUM(), DVAR() and DVARP() Database functions
- Bugfix: (MBaker) Work item 14888 - Simple =IF() formula disappears
- Bugfix: (MBaker) Work item 14898 - PHP Warning: preg_match(): Compilation failed: PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X
- Bugfix: (MBaker) Work item 14901 - VLOOKUP choking on parameters in PHPExcel.1.7.5/PHPExcel_Writer_Excel2007