1

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 Answers1

0

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

Jim K
  • 12,824
  • 2
  • 22
  • 51
  • I did try that at first, and that did not fix it, and I was going off of apache's documentation found on line 256 here http://www.openoffice.org/xml/xml_specification.pdf – user2303120 Dec 07 '16 at 00:17
  • Well after making the change, it worked for me, as shown in the picture. What operating system and version of Office are you using? The PDF document you linked is from 2002, so perhaps the syntax is outdated. – Jim K Dec 07 '16 at 06:26
  • I tested it with Apache OpenOffice 4.1.3 on Windows. – Jim K Dec 07 '16 at 06:33
  • I tried changing it again just to be sure, and I still have the same results. Also I am using the same version, screenshot has been posted in my edit to the issue. – user2303120 Dec 08 '16 at 18:19
  • The edited code gave me an error. It says `text:p p` several times, which OpenOffice rejected. After changing those to just `text:p`, again I had to change the tag to `table-properties` and then it worked. – Jim K Dec 09 '16 at 05:00
  • Try this: 1) Create a blank ODT document. 2) Insert a table with 4 columns and 2 rows. 3) Save the document and then unzip it. 4) Copy and paste the XML that you posted into content.xml. 5) Fix the `text:p p` problems, and change `style:properties` to `style:table-properties`. 6) Zip it back up using a different file name. Does the problem still occur? If so, then I am at a loss to explain it. – Jim K Dec 09 '16 at 05:05