Page 1 of 1

Coloring table rows alternatively on an OpenTope Template

PostPosted: Thu Aug 13, 2015 3:55 am
by mailtomanu
Hi Team,

I have a requirement where the rows in an OpenTope template needs to have different shades alternatively. Basically I will be binding the xml data elements to the Docx template created by OpenTope, where the table rows needs to appear in alternating colors. The solution I thought was to create a base template with a table which has two rows, each with a different shade. I would then wrap these two rows in a single od:repeat. For coloring rows alternatively, I would add a od:condition in each row, which makes that particular row appear in the document only if it meets the condition based on the element being iterated (for example, the position of the element or an Xpath expression evaluating the index).

The problem I am facing now is that there is no way to add an od:repeat surrounding two rows in a table with OpenTope. I think this is the default behaviour of the plugin. Can somebody suggest some alternatives for achieving the above requirement? Manipulating the XML content of the docx with JAXB would be an option , but we prefer to take it as the last option as we need the OpenTope template to be dynamic.

Any help or suggestion is highly appreciated!

Thanks and Regards,
Manu

Re: Coloring table rows alternatively on an OpenTope Templat

PostPosted: Thu Aug 13, 2015 12:19 pm
by jason
Why don't you just use w:cnfStyle

http://webapp.docx4java.org/OnlineDemo/ ... yle_3.html

• Band 1 Horizontal - Does this receive band 1 formatting? This property specifies whether the cell should receive the formatting specified for odd-numbered rows (e.g. 1,3,5,...)

• Band 2 Horizontal - Does this receive band 2 formatting? This property specifies whether the cell should receive the formatting specified for even-numbered rows (e.g. 2,4,6...)

Re: Coloring table rows alternatively on an OpenTope Templat

PostPosted: Fri Aug 14, 2015 2:22 pm
by mailtomanu
Hello Jason,

Thanks a lot for your quick reply, in fact your suggestion works fine in the Docx generated, but when we try to convert the same WordProcessingMLPackage object to PDF, the formatting on table is totally lost!

Do you find any reason for this?

Regards,
Manu

Re: Coloring table rows alternatively on an OpenTope Templat

PostPosted: Sun Aug 16, 2015 1:44 am
by mailtomanu
Hi Jason,

What we found was the <w:cnfStyle> applied to table cells are generally ignored during docx to pdf conversion. One work around we applied was to retrieve the cusome style specific to the table and apply the styles attributes to rows programmatically. The transformed WordProcessingMLPackage instance is then given for PDF transformation.

Regards,
Manu