Bug 63401

Summary: XSSFTable.getName throws an error if called before calling setName
Product: POI Reporter: David Gauntt <dmgauntt>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 4.0.x-dev   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: JUnit Test case to illustrate bug 63401
Patch to XSSFSheet.createTable

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:

java.lang.IndexOutOfBoundsException
	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.