Bug 63401 - XSSFTable.getName throws an error if called before calling setName
Summary: XSSFTable.getName throws an error if called before calling setName
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.0.x-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2019-05-04 16:46 UTC by David Gauntt
Modified: 2019-06-22 06:15 UTC (History)
0 users

JUnit Test case to illustrate bug 63401 (3.24 KB, text/plain)
2019-05-04 16:48 UTC, David Gauntt
Patch to XSSFSheet.createTable (3.60 KB, patch)
2019-05-04 17:00 UTC, David Gauntt
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Gauntt 2019-05-04 16:46:40 UTC
If an XSSFTable is created, and getName is called before setName is called, then getName throws an IndexOutOfBounds error.  The simplest way to prevent this is to call setName inside createTable; I will post a patch and a test case shortly.

Stack trace:

	at org.apache.xmlbeans.impl.store.Xobj.remove_attribute(Xobj.java:2287)
	at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTTableImpl.unsetName(Unknown Source)
	at org.apache.poi.xssf.usermodel.XSSFTable.setName(XSSFTable.java:395)
	at org.apache.poi.xssf.usermodel.XSSFTable.getName(XSSFTable.java:384)
Comment 1 David Gauntt 2019-05-04 16:48:08 UTC
Created attachment 36563 [details]
JUnit Test case to illustrate bug 63401
Comment 2 David Gauntt 2019-05-04 17:00:48 UTC
Created attachment 36564 [details]
Patch to XSSFSheet.createTable

This is similar to the patch to bug 62906 and enhancement 63400, but with a comment added before the line that fixes bug 63401.
Comment 3 Dominik Stadler 2019-06-22 06:15:14 UTC
Applied via r1861819 in a slightly different way, some more minor modifications may be pending via bug 63400 and 62906.