Ask Your Question

Why LibreOffice ignore xlsxwriter 'text_wrap' option where MS Excel and Apache OpenOffice do not

asked 2019-01-16 08:22:30 +0100

Aldennis gravatar image

updated 2019-01-16 08:24:13 +0100

I'm creating an excel document using xlsxwriter thorugh python. However, I have a requirement to output the same file in PDF format. I've tried to use the LibreOffice command line option for converting *.xlsx file to PDF but I always end up with an overlapping text. At first, I though I had my code wrong but when I try to open the same file in MS Excel, the row heigth gets adjusted to fit the text. Then I tried installing OpenOffice and open the same file, it too had the row heigt adjusted properly to fit the text.

It was also mentioned in the xlsxwriter github account but gets dismissed saying that

"...there is no guarantee that LibreOffice or any other spreadsheet application will do this and there is nothing in the file format that XlsxWriter can control to automatically adjust the row height.."

So if OpenOffice can get it right how come LibreOffice don't? It's critical for me because I use LibreOffice to convert the Excel format into PDF while preserving most of layout formatting.


image description

OpenOffice 4.1.5

image description

MS Excel 2013

image description

edit retag flag offensive close merge delete


Please file a bug report with a sample xlsx.

Mike Kaganski gravatar imageMike Kaganski ( 2019-01-16 08:30:17 +0100 )edit

Already file the bug report

Aldennis gravatar imageAldennis ( 2019-01-29 00:51:58 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-01-29 23:02:26 +0100

vsfoote gravatar image

updated 2019-01-29 23:02:54 +0100

It does not ignore it.

See tdf#123026 but short answer is that while Excel reads the text wrap and will resize the row to fit, LibreOffice does not for external formats whcih depend on their import filter.

For tdf#62268 LibreOffice now will parse ODF documents where rows have the "Use-optimal-row-height" value set true in response to cells with wrap text and expand the row height.

But for XML with just wrap text like the XlsxWriter, LO import filter sets the value but do nothing for the row height--using the default row height the document provides.

Several ways to work around, easiest is to save to an ODF Spreadsheet format and reopen. Or, edit the imported .XLXS sheet, select the rows needing expansion -> Format Cells: Alignment tab and simply toggle the "Wrap text automatically" check box.

edit flag offensive delete link more


Any advice on how will I do it at the backend? I'm providing two buttons on a web application. One for Excel and the other for PDF.

OpenOffice works fine but I don't know if it has the same command line option to convert XLSX to PDF.

Aldennis gravatar imageAldennis ( 2019-01-31 13:00:32 +0100 )edit

Can LibreOffice handle importing filters like OpenOffice does? Cause OpenOffice works.

Aldennis gravatar imageAldennis ( 2019-02-06 00:46:11 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-01-16 08:22:30 +0100

Seen: 374 times

Last updated: Jan 29 '19