我正在开发一个能生成相当大的ODT文件的应用程序。应用程序将XML写入content.xml、styles.xml等。我正尝试在一个表上设置一些简单的表样式,在生成文件后,我可以验证它在XML端是否如我所期望的那样通过,但当我在字处理器中打开文件时,没有任何样式实际显示出来。我已经将其分解为只尝试使一个简单的表显示一些样式,但这根本不起作用。
在“automatic- style”标签中,我有这个样式片段。
<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>

发布于 2016-12-07 04:20:45
子节点应该是style:table-properties,而不是style: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>

https://stackoverflow.com/questions/41001807
复制相似问题