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

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.

LibreOffice 6.0.6.2

OpenOffice 4.1.5

MS Excel 2013

image description

Please file a bug report with a sample xlsx.

Already file the bug report

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.

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.

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