Bug 62740

Summary: XSSFTable constructor automatically assigns invalid (non-unique) column IDs
Product: POI Reporter: Andrew Frank Prusinowski <afprusin>
Component: XSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: dmgauntt
Priority: P2    
Version: 4.0.0-FINAL   
Target Milestone: ---   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 62758    

Description Andrew Frank Prusinowski 2018-09-19 16:05:57 UTC
By default, XSSFTableColumn IDs have the non-unique value of '1'.  This is interpreted as an invalid table by Microsoft Office Excel.

The somewhat dated 'Create Table' example will reproduce this behavior: (https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java)

When specifying a table and auto-generating the columns via a cell range, XML similar to the following is produced (in 'table1.xml):

<?xml version="1.0" encoding="UTF-8"?>
<table id="1" ref="A1:C3" name="Test" displayName="Test_Table" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><tableColumns count="3"><tableColumn id="1" name="Column1"/><tableColumn id="1" name="Column2"/><tableColumn id="1" name="Column3"/></tableColumns><tableStyleInfo name="TableStyleMedium2" showRowStripes="true" showColumnStripes="true"/></table>

As can be seen, by default, all table columns are assigned a non-unique ID.

This behavior seems to stem from newly introduced logic (lines 285-293) in XSSFTable.java
Comment 1 Greg Woolsey 2018-09-19 17:34:06 UTC
Yep, looks to me like the logic should start with 0 instead of 1, then add 1 after the loop.

I'm working on this now (in case other devs see it too).
Comment 2 Greg Woolsey 2018-09-19 17:34:06 UTC
Yep, looks to me like the logic should start with 0 instead of 1, then add 1 after the loop.

I'm working on this now (in case other devs see it too).
Comment 3 Greg Woolsey 2018-09-19 17:43:46 UTC
Fixed in r1841357.
Comment 4 Andrew Frank Prusinowski 2018-09-19 18:23:29 UTC
Awesome; thanks for the good work :)
Comment 5 PJ Fanning 2018-09-25 19:42:57 UTC
*** Bug 62758 has been marked as a duplicate of this bug. ***