Bug 120288 - FILESAVE XLSX Default font style affects the height of rows in Excel
Summary: FILESAVE XLSX Default font style affects the height of rows in Excel
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:xlsx
Depends on:
Blocks: XLSX
  Show dependency treegraph
 
Reported: 2018-10-03 16:16 UTC by Gabor Kelemen (allotropia)
Modified: 2022-05-03 11:33 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
The original XLSX file saved with the default font style settings. (14.16 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-10-03 16:16 UTC, Gabor Kelemen (allotropia)
Details
The modified XLSX file saved with Calibri 11pt as default font style. (14.13 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-10-03 16:22 UTC, Gabor Kelemen (allotropia)
Details
The original spreadsheet saved with the default font style settings exported from Microsoft Excel as PDF. (4.99 KB, application/pdf)
2018-10-03 16:23 UTC, Gabor Kelemen (allotropia)
Details
The modified spreadsheet saved with Calibri 11pt as default font style exported from Microsoft Excel as PDF. (95.24 KB, application/pdf)
2018-10-03 16:23 UTC, Gabor Kelemen (allotropia)
Details
A screenshot comparing the two PDF files. The same difference can be observed when the spreadsheets are printed from Excel. (40.35 KB, image/png)
2018-10-03 16:23 UTC, Gabor Kelemen (allotropia)
Details
ODS to start testing from (8.84 KB, application/vnd.oasis.opendocument.spreadsheet)
2019-01-23 12:20 UTC, Buovjaga
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2018-10-03 16:16:27 UTC
Created attachment 145352 [details]
The original XLSX file saved with the default font style settings.

Custom row heights in Microsoft Excel are affected by the default text style set in LibreOffice Calc. LibreOffice Calc uses 10 pt Liberation Sans as its default font. When a spreadsheet created in Calc is saved as XLSX and opened in Microsoft Excel, the row heights appear a bit smaller. The difference isn't obvious at first sight, but it can cause 1-2 cm difference in how the same spreadsheet is rendered by the end of the first page.

The strange thing is, that when the height of the row is checked manually in Excel, it shows (almost) the correct value (with some rounding differences), for example 0,99 cm instead of 1 cm. Printing the document and measuring the rows with a ruler makes it obvious, that in reality the real height of a row is close to 0,93 cm, so the displayed value in Microsoft Excel is incorrect.

If we change the default font style in LibreOffice Calc to Calibri 11pt, save the same spreadsheet again as XLSX, and open it in Excel, the rows are rendered (and printed) exactly as in Calc. It doesn't matter what characters and font sizes are actually used in the spreadsheet, changing the default is enough, even when the default style is not actively used in any cells with content.



Steps to reproduce:

    1. Create a new spreadsheet in LibreOffice Calc. Write something in the first ten rows (like numbers from 1 to 10).
    2. Change the row height for the first then rows to 1 cm.
    3. Save the file as XLSX.
    4. Print the file from LibreOffice Calc and Microsoft Excel and compare the results.
    5. Open the XLSX again in Calc, change the default font style in the Styles and formatting sidebar to Calibri 11.
    6. Save the document again as XLSX, preferably with a new filename to keep the original file for comparison.
    7. Print the spreadsheet from LibreOffice Calc and Microsoft Excel and compare the results again.

Actual results:
The default font style set in LibreOffice Calc affects the height of the rows in Microsoft Excel.

Expected results:
The default font style set in LibreOffice Calc shouldn't affect the height of the rows in Microsoft Excel.

LibreOffice details:
Version: 6.2.0.0.alpha0+
Build ID: 52cb73911e661fb636085337374e09845f07783b
CPU threads: 1; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-10-02_01:05:50
Locale: hu-HU (hu_HU); Calc: threaded
Comment 1 Gabor Kelemen (allotropia) 2018-10-03 16:22:56 UTC
Created attachment 145353 [details]
The modified XLSX file saved with Calibri 11pt as default font style.
Comment 2 Gabor Kelemen (allotropia) 2018-10-03 16:23:17 UTC
Created attachment 145354 [details]
The original spreadsheet saved with the default font style settings exported from Microsoft Excel as PDF.
Comment 3 Gabor Kelemen (allotropia) 2018-10-03 16:23:32 UTC
Created attachment 145355 [details]
The modified spreadsheet saved with Calibri 11pt as default font style exported from Microsoft Excel as PDF.
Comment 4 Gabor Kelemen (allotropia) 2018-10-03 16:23:47 UTC
Created attachment 145356 [details]
A screenshot comparing the two PDF files. The same difference can be observed when the spreadsheets are printed from Excel.
Comment 5 Buovjaga 2019-01-23 12:20:40 UTC
Created attachment 148553 [details]
ODS to start testing from

I repro.

MSO 2013
LibO Version: 6.3.0.0.alpha0+
Build ID: 301ff4dfb82dfd961b993aec151784bd478b4f97
CPU threads: 4; OS: Windows 6.3; UI render: default; VCL: win; 
TinderBox: Win-x86@42, Branch:master, Time: 2019-01-22_22:44:18
Locale: fi-FI (fi_FI); UI-Language: en-US
Calc: threaded
Comment 6 Buovjaga 2019-01-23 12:22:33 UTC
Gábor: would be cool, if you could regression test.
Comment 7 NISZ LibreOffice Team 2019-02-13 10:49:05 UTC
Reproduciable with:

LibreOffice 3.5.0rc3 
Build ID: 7e68ba2-a744ebf-1f241b7-c506db1-7d53735
Comment 8 QA Administrators 2021-03-02 03:47:53 UTC Comment hidden (obsolete)
Comment 9 Attila Szűcs 2021-07-28 11:23:33 UTC
I experienced some strange behavior with excel row height: different views write different row heights for the same row, (I think they rounded differently) that make it hard to analyze.
To make it more confuse, the heights what excel export to xlsx (or what displayed/printed) are rounded differently.

It seems Excel is unable to display/print an exacty 10mm height row.. it can display a 10.05mm, or a 9.79mm height row... (even if it state that the row height is 28.25 pt at some views, and exported to xlsx as 28.35pt .. the row displayed/printed as 27.75 pt high)  
it sems excel round down the 10mm to 9.79mm here.
that is why 26 piece of 10mm height row fit in 257mm. :)

Calc seems to be very precise .. its rounding error is way less then 0.01mm.. so, only 25 piece of 10mm height row fit in 257mm.

So i think this bug is the excel fault.
But we could simulate the excel roundings at import time, if we can recognize that the xlsx was exported by excel.
Comment 10 László Németh 2021-09-15 12:09:09 UTC
"When you change the width of a column to a fractional number, the column width may be set to a different number depending on the font used in the Normal style. For example, with a Normal style font of Arial, if you attempt to change the width of a column to 8.5, the column is set to 8.57 or 65 pixels. This behavior occurs because of the translation of font characters to pixel units. Fractional pixel units cannot be displayed; therefore, the column width rounds to the nearest number that results in a whole pixel unit." Source: https://docs.microsoft.com/en-us/office/troubleshoot/excel/determine-column-widths
Comment 11 László Németh 2021-09-15 13:30:35 UTC
Attila has found a 0.75 pt rounding, which seems to be the factor between 96 ppi of Windows resolution and (originally) 72 ppi of monitor resolutions:

https://en.wikipedia.org/wiki/Dots_per_inch#Computer_monitor_DPI_standards
Comment 12 Xisco Faulí 2022-05-03 11:33:30 UTC
Dear Attila Szűcs,
This bug has been in ASSIGNED status for more than 3 months without any
activity. Resetting it to NEW.
Please assign it back to yourself if you're still working on this.