Categories > OpenTBS with PPTX >

Applying text color upon a cell in a table

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Guidodo
Date: 2015-01-23
Time: 12:39

Applying text color upon a cell in a table

Hello all,

I found OpenTBS only yesterday and I'm particulary interested on PPTX manipulation wich seems really great and powerful.

I've got a pptx model in wich i've drawn a simple table.
I putted a [onshow.var5] tag in a cell and the value is correctly displayed in the output file.

Unfortunately, I'm trying now to apply a color for specific values of my "$var5". For example : red if $var5 < 10 and blue if $var5 > 10.

I searched on the forum and doc but I haven't found anything like that (or maybe I didn't search well).

Thanks for your help !
Nicolas
By: Skrol29
Date: 2015-01-24
Time: 23:03

Re: Applying text color upon a cell in a table

Hi Guidodo,

The dimpliest way is to use one conditional field per format.

For example this TBS field is displayed only if the value is >10.
Parameter "magnet=a:r" will delete the element <a:r> if the value is an empty string. This XML element is for a piece of text in a slide.
[onshow.var5;if [val]+-10;then '';magnet=a:r]

The other solution is to use parameter "onformat" with a function that return the color code (such as "FF0000").
And then us parameter "att" to move the TBS field inside the color attribute of the XML element.
Note that you will need to previously define a color on the TBS field. A custom color, not a theme color.
[onshow.var5;onformat=my_function;att=a:srgbClr#val]
By: Guidodo
Date: 2015-01-26
Time: 10:18

Re: Applying text color upon a cell in a table

Thanks for help Skrol29.

First example works great, magnet param is what was missing in my first tries.
But, I've got now a new question : is there possible to add an else if statement ? I tried coding as in php or sql,
but it doesn't seems to work.

For example I tried: 
[onshow.var5;if [val]=10;then [val];else if [val] = 20; then [val] ;magnet=a:r]
where [val] on else param is put in red of green directly in PPTX model. My need is to test 3 differents values (< 80; [80-120]; > 120) and assign one specific color.

I think it's the other solution you spoke about, but I don't really understand it.
Is there a specific syntax (array ?) to use on php side ?

Thanks for all !

By: Skrol29
Date: 2015-01-27
Time: 00:09

Re: Applying text color upon a cell in a table

By: Guidodo
Date: 2015-01-27
Time: 09:37

Re: Applying text color upon a cell in a table

Just great, I was very close !

Thanks for help and documentation, with that support I'd find everything I need.

Big up for Skrol29 ;)