Table and column width in odt export

== Context ==

I am currently working on pdf and odt (or rtf) export of tables. It works fine for pdf and I am able to nicely format my tables with given column widths.

== Problem==

I could not find a way to have the proper column width in office document exports

== Already tried ==

  • search in the current forum or the old one for table width export
  • format the table using xwiki 2.1 syntax
  • format the table using html

== Question ==

Does anybody knows a way to force a specific width for the columns of a table in an office export ?


Here is my test document:

= Title =

== Content ==

This is just a simple test.

== A table ==

(% style="width:14cm" summary="Example" %)
|a|111
|bb|22
|ccc|3

{{html}}

<h2>Another table</h2>
<table>
  <colgroup>
    <col style='width: 6cm'/>
    <col style='width: 6cm'/>
  </colgroup>
  <theader><tr><th>col1</th><th>col2</th></tr></theader>
  <tbody>
    <tr><td>a</td><td>1</td></tr>
    <tr><td>b</td><td>2</td></tr>
  </tbody>
</table>

{{/html}}

I get the expected widths in the pdf export, but only minimal widths in the office exports. For references, I am using version 10.11.9 of XWiki and 5.2.6.2 of LibreOffice.

Hi @sba

as far as I can see, it’s a problem on LibreOffice side: when exporting the document you mentioned, the resulted HTML contains the following:

table style="width:14cm" summary="Example"><tbody><tr><td>a</td><td>111</td></tr><tr><td>bb</td><td>22</td></tr><tr><td>ccc</td><td>3</td></tr></tbody></table>

and

<table>
  <colgroup>
    <col style="width: 6cm" />
    <col style="width: 6cm" />
  </colgroup>
  <tbody><tr><th>col1</th><th>col2</th></tr>
  </tbody><tbody>
    <tr><td>a</td><td>1</td></tr>
    <tr><td>b</td><td>2</td></tr>
  </tbody></table>

So the HTML is good and correctly rendered (see column-size-export.txt (2.2 KB)), now if you try to open directly this HTML with LibreOffice you’ll see that this style is lost.

@surli

Thanks for this answer.

Do you suggest that the solution could be in upgrading my LibreOffice installation, or that Apache OpenOffice could perform better?

Exporting documents containing tables does not seem really strange to me, so I am surprised that it does not work out of the box and I could not find any reference to that in all the docs I have read (except a question with no solution from 2010 in the old forum).

It is not at all a rant against XWiki (nor of course against your answer). I was just wondering whether you could have that working, and what could be a correct configuration?

I personally tested with LibreOffice 6.3.2.2 which is latest stable version, so upgrading for you won’t change anything. Regarding Apache OpenOffice, I really don’t know.

I had a quick look on the libreoffice bug tracker, but most of the issues I can find close to the subject are about exporting libreoffice documents to HTML, so it’s not the most common usecase I guess to import from HTML with libreoffice. Best would be to open a new bug for them about this.

1 Like

Thank you. It is not really what I expected, but at least I now know what next step should be…

I’m going to open it FYI.
Edit: It’s opened there: https://bugs.documentfoundation.org/show_bug.cgi?id=128492

1 Like