-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
I've been encountering an NPE in OdfTable#getRowByIndex:
java.lang.NullPointerException: Cannot invoke "org.odftoolkit.odfdom.doc.table.OdfTableRow.getOdfElement()" because "row" is null
at org.odftoolkit.odfdom.doc.table.OdfTable.getRowByIndex(OdfTable.java:1774)
at org.odftoolkit.odfdom.doc.TableTest.testTableWithHeaderRowBetweenTableRows(TableTest.java:160)
This happens with a real document of ours (which is created by converting an .xls file to .ods using libreoffice), the content.xml itself basically looks like this:
<table:table table:name="Table1" table:style-name="a87908b">
<table:table-header-columns>
<table:table-column table:number-columns-repeated="1" table:style-name="a035d70"/>
</table:table-header-columns>
<table:table-column table:number-columns-repeated="0" table:style-name="a035d70"/>
<table:table-row>
<table:table-cell>
<text:p>table-row</text:p>
</table:table-cell>
</table:table-row>
<table:table-header-rows>
<table:table-row>
<table:table-cell>
<text:p>table-header-row</text:p>
</table:table-cell>
</table:table-row>
</table:table-header-rows>
<table:table-row>
<table:table-cell>
<text:p>table-row</text:p>
</table:table-cell>
</table:table-row>
</table:table>
The troublesome part is that a <table:table-header-rows> element is prepended by an <table:table-row> element, OdfTable#getRowByIndex and getHeaderRowByIndex are not built to handle this, instead they assume that table-header-rows always comes first in a table. Calling OdfTable.getRowByIndex(1) in this example causes a NullPointerException to be thrown
Metadata
Metadata
Assignees
Labels
No labels