2016-12-06 99 views
1

我正在研究生成大型ODT文件的應用程序。應用程序將XML寫入content.xml,styles.xml等。我試圖在表格中獲取一些簡單的表格樣式,並且在生成文件後,我可以驗證它是否都通過XML端進行驗證我期望它,但是當我在文字處理器中打開文件時,沒有任何樣式實際顯示。我已經把它分解成只是試圖讓簡單的表格顯示一些樣式,甚至根本不工作。XML中的ODT表格樣式不起作用

在「自動樣式」標籤中,我有這個樣式片段。

<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

+0

你能發佈什麼樣的表看起來像在作家的屏幕截圖? –

+0

我在編輯以及content.xml中添加了一個屏幕截圖 – user2303120

回答

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

+0

我確實嘗試過,但沒有解決它,並且我在這裏找到了第256行的apache文檔。 /www.openoffice.org/xml/xml_specification.pdf – user2303120

+0

完成更改後,它對我有用,如圖所示。您使用的是哪種操作系統和Office版本?您鏈接的PDF文檔是從2002年開始的,因此語法可能已過時。 –

+0

我在Windows上用Apache OpenOffice 4.1.3測試了它。 –