Bug 62740 - XSSFTable constructor automatically assigns invalid (non-unique) column IDs
Summary: XSSFTable constructor automatically assigns invalid (non-unique) column IDs
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 4.0.0-FINAL
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 62758 (view as bug list)
Depends on:
Blocks: 62758
  Show dependency tree
 
Reported: 2018-09-19 16:05 UTC by Andrew Frank Prusinowski
Modified: 2018-09-25 19:42 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***