Page 1 of 1

xhtml import - table issues

PostPosted: Thu Apr 19, 2012 2:01 am
by skyvic
Hello,

Today I'm trying to convert an HTML Document to DOCX Document.

I made several tests on Table conversion and I have an error in some cases when I'm using "colspan" :

In this case, it works :
Code: Select all
<table border="1">
   <tbody>
   <tr><td colspan="2"><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td></tr>
   <tr><td><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td><td><p>Bouh</p></td></tr>
   <tr><td><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td><td><p>Bouh</p></td></tr>
   </tbody>
</table>


But, in this case, there is an error ("java.lang.NullPointerException") :
Code: Select all
<table border="1">
   <tbody>
   <tr><td><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td></tr>
   <tr><td colspan="2"><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td><td><p>Bouh</p></td></tr>
   <tr><td><p>Name</p></td><td><p>Age</p></td><td><p>Bouh</p></td><td><p>Bouh</p></td></tr>
   </tbody>
</table>


Is this a bug or anything else ?

Thanks for your answers.

skyvic

Re: xhtml import - table issues

PostPosted: Thu Apr 19, 2012 1:15 pm
by jason
Looks like a bug. I haven't got much time to look at this over next few days, but I'd like to include a fix for it in 2.8.0

Re: xhtml import - table issues

PostPosted: Thu Apr 26, 2012 10:04 pm
by jason
That table is bad, in that row 2 contains more cells than row 1. You can check it at http://www.mtholyoke.edu/help/syntax/tablecheck.shtml

It is still not ideal that it throws an NPE though; http://www.docx4java.org/trac/docx4j/changeset/1806 fixes that. I've also changed the convert API so that it throws a Docx4JException.