TinyButStrong - the PHP Template Engine
Categories > OpenTBS with ODT >

Change color of table cells in ODT

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs

By: Tom Hansen
Date: 2015-10-28
Time: 13:11

Change color of table cells in ODT

I am trying to change the color of table cells in an ODT document.

The template looks like:

<style:style style:name="P10" style:family="paragraph" style:parent-style-name="Table_20_Contents">
<style:paragraph-properties fo:background-color="transparent"><style:background-image/>
</style:paragraph-properties>
<style:text-properties officeooo:rsid="00106c95" officeooo:paragraph-rsid="000b9856" fo:background-color="transparent"/>
</style:style>
...
<style:style style:name="T4" style:family="text"><style:text-properties officeooo:rsid="002648e6"/></style:style>
...
<table:table-cell table:style-name="Table1.B2" office:value-type="string">
<text:p text:style-name="P10"><text:span text:style-name="T4">Xyz </text:span>[a.col;att=fo:background][a.sn;att=text:style-name]</text:p>
</table:table-cell>

In PHP I do the following after an sql query (setting the background-color and removing the style-name which might otherwise overwrite the background-color)
while ($row=mysql_fetch_object($res)) {
  $d=array("sn"=>"","col"=>"#00ffff",...);
  $data[]=$d;
}
//...
$TBS->MergeBlock('a',$data);

The result is quite strange:
<table:table-cell table:style-name="Table1.B2" office:value-type="string">
            <text:p text:style-name="" fo:background="[]"#00ffffyz </text:p>
            </table:table-cell>

The style-name deletion seems to work. But the (previously not existing) fo:background attribute should just be added to the text:p tag, shouldn't it?
However, it looks like some replacements got mixed up??
Any idea what I did wrong and/or how to do it correctly? Or is it a bug in TBS?
I am quite new to TBS, so detailed explanations or hints to a good description of the "att" usage are welcome.

Thanks in advance!