1
votes

I'm working on an application that generates a sizeable ODT file. The app writes the XML to the content.xml, styles.xml, etc. I'm trying to get some simple table styling through on a table, and after generating the file, I can verify it's all coming through on the XML side as I'd expect it to, but none of the styling is actually showing when I open the file in the word processor. I've broken it down to just trying to make a simple table show some styles, and even that's not working at all.

Within the "automatic-styles" tag, I have this style snippet.

    <style:style style:name="mytable" style:family="table">
        <style:properties 
            fo:background-color="#666666" 
            style:width="445.5pt" 
            fo:margin-left="4.5pt" 
            fo:margin-top="0pt" 
            fo:margin-bottom="0pt" 
            table:align="left" 
        />
    </style:style>
    <style:style style:name="mytable.A" style:family="table-column">
        <style:properties fo:background-color="#000000" style:column-width="117pt"/>
    </style:style>
    <style:style style:name="mytable.B" style:family="table-column">
        <style:properties style:column-width="103.5pt"/>
    </style:style>
    <style:style style:name="mytable.C" style:family="table-column">
        <style:properties style:column-width="193.5pt"/>
    </style:style>
    <style:style style:name="mytable.D" style:family="table-column">
        <style:properties style:column-width="31.5pt"/>
    </style:style>  

EDIT: Here is a screenshot of my live document. This is the content.xml portion from this exact document, the style posted above is the same.

    <table:table table:name="mytable" table:style-name="mytable">
        <table:table-columns>
            <table:table-column table:style-name="mytable.A"/>
            <table:table-column table:style-name="mytable.B"/>
            <table:table-column table:style-name="mytable.C"/>
            <table:table-column table:style-name="mytable.D"/>
        </table:table-columns>
        <table:table-header-rows>
            <table:table-row>
                <table:table-cell table:style-name="mytable.A1" office:value-type="string">
                    <text:p text:style-name="P39">citation</text:p>
                </table:table-cell>
                <table:table-cell table:style-name="mytable.B1" office:value-type="string">
                    <text:p text:style-name="P39">title</text:p>
                </table:table-cell>
                <table:table-cell table:style-name="mytable.C1" office:value-type="string">
                    <text:p text:style-name="P39">description</text:p>
                </table:table-cell>
                <table:table-cell table:style-name="mytable.D1" office:value-type="string">
                    <text:p p text:style-name="P38"/>
                </table:table-cell>
            </table:table-row>
        </table:table-header-rows>
        <table:table-row>
            <table:table-cell table:style-name="mytable.A2" office:value-type="string">
                <text:p p text:style-name="P39">Administrative Safe-guards</text:p>
            </table:table-cell>
            <table:table-cell table:style-name="mytable.B2" office:value-type="string">
                <text:p p text:style-name="P39"/>
            </table:table-cell>
            <table:table-cell table:style-name="mytable.C2" office:value-type="string">
                <text:p p text:style-name="P39"/>
            </table:table-cell>
            <table:table-cell table:style-name="mytable.D2" office:value-type="string">
                <text:p p text:style-name="P38"/>
            </table:table-cell>
        </table:table-row>
    </table:table>

screenshot

1
Could you post a screen capture of what the table looks like in Writer? - Jim K
I added a screenshot to the edit as well as the actual xml in the content.xml - user2303120

1 Answers

0
votes

Instead of style:properties, the child node should be style:table-properties. This is explained at http://books.evc-cit.info/odbook/ch04.html#text-table-style-section.

<office:automatic-styles>
<style:style style:name="mytable" style:family="table">
    <style:table-properties 
        fo:background-color="#666666" 
        style:width="445.5pt" 
        fo:margin-left="4.5pt" 
        fo:margin-top="0pt" 
        fo:margin-bottom="0pt" 
        table:align="left" 
    />
</style:style>

table style