Skip to content

Commit

Permalink
Refactor the Excel Database functions; and rewrite the query building (
Browse files Browse the repository at this point in the history
…#1871)

* Refactor the Excel Database functions; and rewrite the query building to fix a bug with complex multi-criteria queries that involve both AND and OR conditions
* Fix handling for empty cells and NULL values in searches
* Expand unit tests; and add TODOs for dates, percentages, and wildcard text comparisons
  • Loading branch information
Mark Baker authored Feb 22, 2021
1 parent 1318b90 commit 3764f30
Show file tree
Hide file tree
Showing 27 changed files with 2,034 additions and 256 deletions.
25 changes: 13 additions & 12 deletions src/PhpSpreadsheet/Calculation/Calculation.php
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ class Calculation
],
'DAVERAGE' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DAVERAGE'],
'functionCall' => [Database\DAverage::class, 'evaluate'],
'argumentCount' => '3',
],
'DAY' => [
Expand Down Expand Up @@ -799,12 +799,12 @@ class Calculation
],
'DCOUNT' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DCOUNT'],
'functionCall' => [Database\DCount::class, 'evaluate'],
'argumentCount' => '3',
],
'DCOUNTA' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DCOUNTA'],
'functionCall' => [Database\DCountA::class, 'evaluate'],
'argumentCount' => '3',
],
'DDB' => [
Expand Down Expand Up @@ -849,7 +849,7 @@ class Calculation
],
'DGET' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DGET'],
'functionCall' => [Database\DGet::class, 'evaluate'],
'argumentCount' => '3',
],
'DISC' => [
Expand All @@ -859,12 +859,12 @@ class Calculation
],
'DMAX' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DMAX'],
'functionCall' => [Database\DMax::class, 'evaluate'],
'argumentCount' => '3',
],
'DMIN' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DMIN'],
'functionCall' => [Database\DMin::class, 'evaluate'],
'argumentCount' => '3',
],
'DOLLAR' => [
Expand All @@ -884,22 +884,22 @@ class Calculation
],
'DPRODUCT' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DPRODUCT'],
'functionCall' => [Database\DProduct::class, 'evaluate'],
'argumentCount' => '3',
],
'DSTDEV' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DSTDEV'],
'functionCall' => [Database\DStDev::class, 'evaluate'],
'argumentCount' => '3',
],
'DSTDEVP' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DSTDEVP'],
'functionCall' => [Database\DStDevP::class, 'evaluate'],
'argumentCount' => '3',
],
'DSUM' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DSUM'],
'functionCall' => [Database\DSum::class, 'evaluate'],
'argumentCount' => '3',
],
'DURATION' => [
Expand All @@ -909,12 +909,12 @@ class Calculation
],
'DVAR' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DVAR'],
'functionCall' => [Database\DVar::class, 'evaluate'],
'argumentCount' => '3',
],
'DVARP' => [
'category' => Category::CATEGORY_DATABASE,
'functionCall' => [Database::class, 'DVARP'],
'functionCall' => [Database\DVarP::class, 'evaluate'],
'argumentCount' => '3',
],
'EDATE' => [
Expand Down Expand Up @@ -3437,6 +3437,7 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $pCell =
$this->debugLog->writeDebugLog('Formula for cell ', $wsCellReference, ' is ', $formula);
// Parse the formula onto the token stack and calculate the value
$this->cyclicReferenceStack->push($wsCellReference);

$cellValue = $this->processTokenStack($this->internalParseFormula($formula, $pCell), $cellID, $pCell);
$this->cyclicReferenceStack->pop();

Expand Down
Loading

0 comments on commit 3764f30

Please sign in to comment.