You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2021/09/05 19:05:54 UTC

svn commit: r1892951 - /poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java

Author: fanningpj
Date: Sun Sep  5 19:05:54 2021
New Revision: 1892951

URL: http://svn.apache.org/viewvc?rev=1892951&view=rev
Log:
more specific exception instead of NPE

Modified:
    poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java?rev=1892951&r1=1892950&r2=1892951&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java Sun Sep  5 19:05:54 2021
@@ -210,7 +210,6 @@ public final class OperationEvaluationCo
         }
         SheetRangeEvaluator sre = new SheetRangeEvaluator(_sheetIndex, se);
 
-        // ugly typecast - TODO - make spreadsheet version more easily accessible
         SpreadsheetVersion ssVersion = _workbook.getSpreadsheetVersion();
 
         NameType part1refType = classifyCellReference(refStrPart1, ssVersion);
@@ -219,7 +218,11 @@ public final class OperationEvaluationCo
                 return ErrorEval.REF_INVALID;
             case NAMED_RANGE:
                 EvaluationName nm = _workbook.getName(refStrPart1, _sheetIndex);
-                if(!nm.isRange()){
+                if(nm == null) {
+                    throw new RuntimeException("Specified name '" + refStrPart1 +
+                            "' is not found in the workbook (sheetIndex=" + _sheetIndex +").");
+                }
+                if(!nm.isRange()) {
                     throw new RuntimeException("Specified name '" + refStrPart1 + "' is not a range as expected.");
                 }
                 return _bookEvaluator.evaluateNameFormula(nm.getNameDefinition(), this);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org