diff options
author | Nick Burch <nick@apache.org> | 2014-07-21 16:52:19 +0000 |
---|---|---|
committer | Nick Burch <nick@apache.org> | 2014-07-21 16:52:19 +0000 |
commit | ea8e44678b9b132c20276cb5c7d9e01efa922eae (patch) | |
tree | 976d537eca0dba0bcb031af04facdb887166c885 | |
parent | 70f40542fd5c4b246e9f3a837fb5fa9cd9b445fe (diff) | |
download | poi-ea8e44678b9b132c20276cb5c7d9e01efa922eae.tar.gz poi-ea8e44678b9b132c20276cb5c7d9e01efa922eae.zip |
Use the link table when looking up external xssf names
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1612347 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java index fd5bb0366d..d9d53f7ce4 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationWorkbook.java @@ -135,14 +135,21 @@ public final class XSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E // 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? } } |