XML中的ODT表样式不起作用

时间:2016-12-06 17:55:05

标签: xml openoffice-writer odt

我正在处理一个生成相当大的ODT文件的应用程序。该应用程序将XML写入content.xml,styles.xml等。我试图通过一个表格获得一些简单的表样式,并在生成文件后,我可以验证它是否全部到来正如我所期望的那样,通过XML方面,但是当我在文字处理器中打开文件时,没有任何样式实际显示。我把它分解成只是试图让一个简单的表格显示一些风格,甚至那根本不起作用。

在"自动样式"标签,我有这个样式片段。

    <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>  

编辑:这是我的实时文档的屏幕截图。这是来自此文档的content.xml部分,上面发布的样式是相同的。

    <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 个答案:

答案 0 :(得分:0)

而不是style:properties,子节点应为style:table-properties。这在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