diff options
author | PJ Fanning <fanningpj@apache.org> | 2020-06-27 10:08:14 +0000 |
---|---|---|
committer | PJ Fanning <fanningpj@apache.org> | 2020-06-27 10:08:14 +0000 |
commit | 33261cd4d2bd88b279dd32f9ada75bfa4dd41d2b (patch) | |
tree | 2834d61c74ede938d0e96c4d920c444429324d5b | |
parent | e43cbf5d46424942112e82f8573ae3c2a5823fee (diff) | |
download | poi-33261cd4d2bd88b279dd32f9ada75bfa4dd41d2b.tar.gz poi-33261cd4d2bd88b279dd32f9ada75bfa4dd41d2b.zip |
try to fix test compile
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1879257 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 22a737c413..9a53d24d1e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -1019,6 +1019,25 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su } /** + * Get the named range at the given index. No longer public and only used in tests. + * + * @param nameIndex the index of the named range + * @return the XSSFName at the given index + */ + @Deprecated + XSSFName getNameAt(int nameIndex) { + int nNames = namedRanges.size(); + if (nNames < 1) { + throw new IllegalStateException("There are no defined names in this workbook"); + } + if (nameIndex < 0 || nameIndex > nNames) { + throw new IllegalArgumentException("Specified name index " + nameIndex + + " is outside the allowable range (0.." + (nNames-1) + ")."); + } + return namedRanges.get(nameIndex); + } + + /** * Get a list of all the named ranges in the workbook. * * @return list of XSSFNames in the workbook @@ -1029,6 +1048,24 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su } /** + * Gets the named range index by name. No longer public and only used in tests. + * + * @param name named range name + * @return named range index. <code>-1</code> is returned if no named ranges could be found. + * + * @deprecated 3.16. New projects should avoid accessing named ranges by index. + * Use {@link #getName(String)} instead. + */ + @Deprecated + int getNameIndex(String name) { + XSSFName nm = getName(name); + if (nm != null) { + return namedRanges.indexOf(nm); + } + return -1; + } + + /** * Get the number of styles the workbook contains * * @return count of cell styles @@ -1225,9 +1262,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su } /** - * As {@link #removeName(String)} is not necessarily unique - * (name + sheet index is unique), this method is more accurate. - * * @param name the name to remove. * * @throws IllegalArgumentException if the named range is not a part of this XSSFWorkbook |