]> source.dussan.org Git - poi.git/commitdiff
60823: DGET function, correct behavior with multiple result entries but only one...
authorDominik Stadler <centic@apache.org>
Sun, 19 Mar 2017 20:29:55 +0000 (20:29 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 19 Mar 2017 20:29:55 +0000 (20:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1787658 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/formula/functions/DGet.java
test-data/spreadsheet/DGet.xls

index 0bf9cc2623bcfab088f98348be8cfc42a353c76f..5cdc29251d694206101f7da89da552f427d2f781 100644 (file)
@@ -36,10 +36,18 @@ public final class DGet implements IDStarAlgorithm {
         {
             result = eval;
         }
-        else // There was a previous match, since there is only exactly one allowed, bail out.
+        else // There was a previous match. Only one non-blank result is allowed. #NUM! on multiple values.
         {
-            result = ErrorEval.NUM_ERROR;
-            return false;
+            if(result instanceof BlankEval) {
+                result = eval;
+            }
+            else {
+                // We have a previous filled result.
+                if(!(eval instanceof BlankEval)) {
+                    result = ErrorEval.NUM_ERROR;
+                    return false;
+                }
+            }
         }
 
         return true;
index 729e974e4dfd4bf2e06b10c620cbb17b4b6bf719..49514d20f5651aba79c83feb6511d6128e24bf46 100644 (file)
Binary files a/test-data/spreadsheet/DGet.xls and b/test-data/spreadsheet/DGet.xls differ