Page 1 of 1

Transformation Issue while adding tables

PostPosted: Wed Jan 20, 2016 4:04 am
by kummethab
Hi

I am using docx4j-3.2.2.jar to create dynamic Headers, Footers and Table in content place by reading and identifying unique keyword (REVIEW AND REVISION HISTORY) in document. I am not getting any error during the process. But when i try to open the transformed document in MS office 7 i am getting unspecified error at Location:Part:/word/document.xml (PFA). While if i add any paragragh instead of table i am not facing any issue. I have attached the transformed document. Kindly suggest.

MS Office Version Using: 12.0.6735.5000 SP3 MSO.




Regards,

Krishna Kumar

Re: Transformation Issue while adding tables

PostPosted: Thu Jan 21, 2016 1:38 pm
by jason
Your document "with table - error" opens fine for me in 2010 (v14). I haven't tried it in 2007.

Microsoft's OpenXML SDK 2.0 Productivity Tool says it fails validation.

Try adding:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
      <w:tblGrid>
        <w:gridCol w:w="1486"/>
        <w:gridCol w:w="2071"/>
        <w:gridCol w:w="2961"/>
        <w:gridCol w:w="2702"/>
      </w:tblGrid>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4

Re: Transformation Issue while adding tables

PostPosted: Thu Jan 21, 2016 6:56 pm
by kummethab
Hi Jason,

Thanks for your reply. My issue got resolved.

Problem was I have hardcoded the table width parameters in my code. MS word 7 does have that capability to take that. Later i changed parameter to below. Then it works fine for me.
int tableWidthParam = wordMLPackage.getDocumentModel().getSections().get(0).getPageDimensions().getWritableWidthTwips();
int noofCol = 4;
int cellWidth = new Double(Math.floor((tableWidthParam / noofCol ))).intValue();