1

I am trying to write in org mode and then export to an odt file. But some tables are better edited in libreoffice, can I include an external odt file that contains the table in org mode? Is there any org keyword for libreoffice's master document?

1

Here is how I would do that. Create through libreoffice (or whatever you want, I tried with abiword) a table.odt file containing the table. Then copy the xml table code (the <table:table> element) from the content.xml file inside table.odt (which actually is a zip file) into file table.org, inside #+BEGIN/END_ODT.

I tried this and created the following table.org file:

#+BEGIN_ODT
   <table:table table:name="Table1">
    <table:table-column/>
    <table:table-column/>
    <table:table-row>
     <table:table-cell table:style-name="Table1_col1_row1">
      <text:p text:style-name="P1" >1</text:p>
     </table:table-cell>
     <table:table-cell table:style-name="Table1_col2_row1">
      <text:p text:style-name="P2" >2</text:p>
     </table:table-cell>
    </table:table-row>
    <table:table-row>
     <table:table-cell table:style-name="Table1_col1_row2">
      <text:p text:style-name="Normal" >3</text:p>
     </table:table-cell>
     <table:table-cell table:style-name="Table1_col2_row2">
      <text:p text:style-name="P1" >4</text:p>
     </table:table-cell>
    </table:table-row>
   </table:table>
#+END_ODT

Finally, #+include table.org in your main org file.

#+INCLUDE: "~/table.org"

Exporting the main org file to odt does include the table as expected (in this simple example at least). Of course you need to recreate the table.org file each time you edit the table. But I'm confident you could automate this with some shell (or whatever, certainly including emacs!) scripting:

  • extract content.xml from odt,
  • get element from content.xml (eg with sed),
  • dump this to table.org, enclosed in #+BEGIN/END_ODT
  • Perfect. So now create a odt file for each table or multi-column section, and use a script to remove all unecessary part not related to the content of intereste. Or maybe the script to remove is simpler than the script to extract? – godblessfq Aug 12 '16 at 1:45
  • @godblessfq Extracting seems easier to me, something like sed -n '/<table:table/,/<\/table:table>/p' content.xml (Assuming only one table in content.xml, of course). – JeanPierre Aug 14 '16 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.