2016-12-06 3 views
1

Je travaille sur une application qui génère un fichier ODT important. L'application écrit le XML dans le fichier content.xml, styles.xml, etc. J'essaie d'obtenir un style de table simple sur une table, et après avoir généré le fichier, je peux vérifier que tout se passe du côté XML. Je m'y attendais, mais aucun style n'apparaît lorsque j'ouvre le fichier dans le traitement de texte. Je l'ai décomposé simplement en essayant de faire un simple tableau de styles, et même cela ne fonctionne pas du tout.Les styles de table ODT en XML ne fonctionnent pas

Dans la balise "styles automatiques", j'ai cet extrait de 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> 

EDIT: Voici une capture d'écran de mon document en direct. C'est la partie content.xml de ce document, le style affiché ci-dessus est le même.

<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

Pouvez-vous poster une capture d'écran de ce que la table ressemble dans Writer? –

+0

J'ai ajouté une capture d'écran à l'édition ainsi que le xml réel dans le content.xml – user2303120

Répondre

0

Au lieu de style:properties, le nœud enfant doit être style:table-properties. Ceci est expliqué au 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

J'ai essayé cela au début, et cela ne l'a pas réparé, et je partais de la documentation d'apache trouvée sur la ligne 256 ici http://www.openoffice.org/xml/xml_specification.pdf – user2303120

+0

Bien après avoir fait le changement, cela a fonctionné pour moi, comme indiqué dans l'image. Quel système d'exploitation et quelle version d'Office utilisez-vous? Le document PDF que vous avez lié date de 2002, donc la syntaxe est peut-être dépassée. –

+0

Je l'ai testé avec Apache OpenOffice 4.1.3 sous Windows. –