Categories > OpenTBS with DOCX >

Changing font colour inside tables

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Fully
Date: 2015-09-05
Time: 15:24

Changing font colour inside tables

Hi,
I've got a Word document with a table containing multiple rows of text with different colours/shading a bit like:

|Row one text|Info|   - Cell shading black, text white
|Row two text|Info|    - Cell shading green, text blue
|Row three text|Info| - Cell shading red, text black
|Row four text|Info|   - Cell shading red, text black

Number of rows can vary from 1 to 20+ so hiding certain colour combinations isn't an option really.

I can change the row colours OK depending on a range value but am also trying to change the colours of the text at the same time, I'm using this code in the Word doc:
[tmptable.title;block=tbs:row][tmptable.rowColour;att=w:shd#w:fill][tmptable.textColour;att=w:color#w:val]

Getting an "entity targeted by parameter 'att' cannot be found" for textColour which is due to the block target being tbs:row rather than the text inside the cell. I've tried using w:t in various places but cannot work it out for the life of me!

Is it possible to change two attributes in this way? Any info or workarounds welcomed.

Cheers, Fully
By: Skrol29
Date: 2015-09-07
Time: 01:22

Re: Changing font colour inside tables

Hi,

It is possible to have several fields with "att" in the same block.
The only know limitation is « Method MergeBlock() cannot move a TBS field over another TBS field placed after it. This makes a TBS error to occur. »
But your snippet is ok regarding to this rule.

You have to check one thing: if your text color in the template is a theme color, then there is no element <w:color w:val="...">. Checked that the color in a standard color, and alos check the content of sub-file « document.xml ».
By: Fully
Date: 2015-10-12
Time: 16:01

Re: Changing font colour inside tables

Hi!
Finally got round to looking at this. The code above was fine but as you said the element was missing! I changed the colour of the text and it all worked a treat!

Thanks for the pointers and the great library :o)
Fully