Page 1 of 1

Table general questions

PostPosted: Fri Aug 11, 2017 6:55 am
by prakhar211
Hi,

1. I have table in the word template and i want to know how to hide or show it using docx4j.
2. how to adjust column/cell width.
3. any suggestion or link to refer some examples.
4. how to wrap text in table cell.
5. how to break data in newlines in a table cell. Example "abc cde efg hij klm nop qrs tuv wxyz". I want to show "abc cde" in the first line and then "efg hij" in the second line in a table cell.

Re: Table general questions

PostPosted: Thu Aug 17, 2017 1:58 pm
by jason
Table layout defaults to "auto layout to fit text" unless you set:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
        <w:tblLayout w:type="fixed"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


Either way, you can probably get away with:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
         <w:tblW w:w="0" w:type="auto"/>
 
Parsed in 0.000 seconds, using GeSHi 1.0.8.4


To size the columns, set a w:tblGrid/w:gridCol value for each column.

If tblLayout is fixed, text will wrap automatically. If it isn't, you'll need soft returns (shift-enter).

As the Helper AddIn or the web-app would show you, that's just w:br in your run:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                Br br = wmlObjectFactory.createBr();
                run.getContent().add( br);
 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4