Page 1 of 1

Table headers

PostPosted: Fri Dec 14, 2012 6:10 pm
by Babak
Hello
When i create docx with table i see:
Image
but if i print document or try change some column width i see:
Image
What could be a problem?
Thanks.

Re: Table headers

PostPosted: Fri Dec 14, 2012 7:26 pm
by jason
Please post a docx exhibiting the issue - anonymised first as you need.

Re: Table headers

PostPosted: Fri Dec 14, 2012 7:42 pm
by Babak
report.docx
(43.26 KiB) Downloaded 311 times

part of document with 2 tables
all tables in my document look like that

Re: Table headers

PostPosted: Fri Dec 14, 2012 9:07 pm
by jason
Your table starts with:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
      <w:tblPr>
        <w:tblStyle w:val="ac"/>
        <w:tblW w:w="0" w:type="auto"/>
        <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
      </w:tblPr>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Changing a column width has the effect of changing this to:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
      <w:tblPr>
        <w:tblStyle w:val="TableGrid"/>
        <w:tblW w:w="0" w:type="auto"/>
        <w:tblLayout w:type="fixed"/>
        <w:tblLook w:val="04A0" w:firstRow="1" w:lastRow="0" w:firstColumn="1" w:lastColumn="0" w:noHBand="0" w:noVBand="1"/>
      </w:tblPr>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


(and adding that style to styles.xml)

It adds an extra w:gridCol (correcting an issue?), and changes your w:tcW/@w:w="0" values to values appropriate for each cell (based on the grid)

If you make these changes manually or using docx4j, you'll see the missing content.

I guess docx4j creeates better PDF output with this adjusted table?

Re: Table headers

PostPosted: Fri Dec 14, 2012 9:53 pm
by Babak
I create TblPr
Code: Select all
        TblPr tblPr = objFactory.createTblPr();
        TblWidth tblWidth = objFactory.createTblWidth();
        tblWidth.setW(TABLE_ALBUM_WIDTH);
        tblWidth.setType(TblWidth.TYPE_DXA); // twips
        tblPr.setTblW(tblWidth);

        TblStyle tblStyle = objFactory.createCTTblPrBaseTblStyle();
        tblStyle.setVal("TableGrid");
        tblPr.setTblStyle(tblStyle);

        CTTblLayoutType layout = objFactory.createCTTblLayoutType();
        layout.setType(STTblLayoutType.FIXED);
        tblPr.setTblLayout(layout);

but it did not help

Re: Table headers

PostPosted: Sat Dec 15, 2012 12:21 am
by Babak
the problem was in Tc
they need
Code: Select all
VMerge vm = objFactory.createTcPrInnerVMerge();
                        vm.setVal("restart");
in TcPr