You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2014/07/21 18:52:20 UTC

svn commit: r1612347 - /poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java

Author: nick
Date: Mon Jul 21 16:52:19 2014
New Revision: 1612347

URL: http://svn.apache.org/r1612347
Log:
Use the link table when looking up external xssf names

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java?rev=1612347&r1=1612346&r2=1612347&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java Mon Jul 21 16:52:19 2014
@@ -135,14 +135,21 @@ public final class XSSFEvaluationWorkboo
             // External reference - reference is 1 based, link table is 0 based
             int linkNumber = externalWorkbookNumber - 1;
             ExternalLinksTable linkTable = _uBook.getExternalLinksTable().get(linkNumber);
-            // TODO Return a more specialised form of this, see bug #56752
-            // Should include the cached values, for in case that book isn't available
-            // Should support XSSF stuff lookups
-            return new ExternalName(nameName, -1, -1);
+            
+            for (org.apache.poi.ss.usermodel.Name name : linkTable.getDefinedNames()) {
+                if (name.getNameName().equals(nameName)) {
+                    // TODO Return a more specialised form of this, see bug #56752
+                    // Should include the cached values, for in case that book isn't available
+                    // Should support XSSF stuff lookups
+                    return new ExternalName(nameName, -1, name.getSheetIndex());
+                }
+            }
+            throw new IllegalArgumentException("Name '"+nameName+"' not found in " +
+                                               "reference to " + linkTable.getLinkedFileName());
         } else {
             // Internal reference
             int nameIdx = _uBook.getNameIndex(nameName);
-            return new ExternalName(nameName, nameIdx, -1);  // TODO Is this right?
+            return new ExternalName(nameName, nameIdx, 0);  // TODO Is this right?
         }
 	    
     }



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