ASF Bugzilla – Attachment 29956 Details for
Bug 54564
[PATCH] Invalid range in error message when accessing out of range sheet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
simple text enhancement and a fix that prints (no sheets) instead of the range
patch.txt (text/plain), 2.30 KB, created by
Florian Hopf
on 2013-02-15 11:20:26 UTC
(
hide
)
Description:
simple text enhancement and a fix that prints (no sheets) instead of the range
Filename:
MIME Type:
Creator:
Florian Hopf
Created:
2013-02-15 11:20:26 UTC
Size:
2.30 KB
patch
obsolete
>Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (Revision 1446506) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (Arbeitskopie) >@@ -1040,8 +1040,12 @@ > private void validateSheetIndex(int index) { > int lastSheetIx = sheets.size() - 1; > if (index < 0 || index > lastSheetIx) { >+ String range = "(0.." + lastSheetIx + ")"; >+ if (lastSheetIx == -1) { >+ range = "(no sheets)"; >+ } > throw new IllegalArgumentException("Sheet index (" >- + index +") is out of range (0.." + lastSheetIx + ")"); >+ + index +") is out of range " + range); > } > } > >Index: src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java >=================================================================== >--- src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (Revision 1446506) >+++ src/testcases/org/apache/poi/ss/usermodel/BaseTestWorkbook.java (Arbeitskopie) >@@ -45,6 +45,8 @@ > fail("should have thrown exceptiuon due to invalid sheet index"); > } catch (IllegalArgumentException e) { > // expected during successful test >+ // no negative index in the range message >+ assertFalse(e.getMessage().contains("-1")); > } > > Sheet sheet0 = wb.createSheet(); >Index: src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java >=================================================================== >--- src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (Revision 1446506) >+++ src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (Arbeitskopie) >@@ -427,8 +427,12 @@ > private void validateSheetIndex(int index) { > int lastSheetIx = _sheets.size() - 1; > if (index < 0 || index > lastSheetIx) { >+ String range = "(0.." + lastSheetIx + ")"; >+ if (lastSheetIx == -1) { >+ range = "(no sheets)"; >+ } > throw new IllegalArgumentException("Sheet index (" >- + index +") is out of range (0.." + lastSheetIx + ")"); >+ + index +") is out of range " + range); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54564
: 29956