diff --git a/Classes/PHPExcel/Calculation.php b/Classes/PHPExcel/Calculation.php index ccaa7823..037acf69 100644 --- a/Classes/PHPExcel/Calculation.php +++ b/Classes/PHPExcel/Calculation.php @@ -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, diff --git a/Classes/PHPExcel/Calculation/Database.php b/Classes/PHPExcel/Calculation/Database.php index 3e267a33..dedfed14 100644 --- a/Classes/PHPExcel/Calculation/Database.php +++ b/Classes/PHPExcel/Calculation/Database.php @@ -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 * diff --git a/changelog.txt b/changelog.txt index 6f0de4f3..fdbf4d64 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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