Bug 159916 - Spreadsheet default alignment is not honored for xlsx format
Summary: Spreadsheet default alignment is not honored for xlsx format
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium trivial
Assignee: Not Assigned
URL: https://github.com/PHPOffice/PhpSprea...
Whiteboard:
Keywords: filter:xlsx, needUITest
Depends on:
Blocks: Calc-Cells
  Show dependency treegraph
 
Reported: 2024-02-26 23:14 UTC by guillaume.alabre
Modified: 2024-03-05 22:04 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
LibreOffice Calc does not respect spreadsheet's defaults (5.98 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2024-02-26 23:17 UTC, guillaume.alabre
Details
xls files are correctly displayed (4.00 KB, application/vnd.ms-excel)
2024-03-05 22:04 UTC, guillaume.alabre
Details

Note You need to log in before you can comment on or make changes to this bug.
Description guillaume.alabre 2024-02-26 23:14:22 UTC
Description:
In LibreOffice Calc, Xlsx Spreadsheets with a default alignment are not honored (UI). The alignment is set to bottom / left / no-wrap in any-case.

This issue was found in https://github.com/PHPOffice/PhpSpreadsheet/issues/3918.

it looks like I should be able to upload files after, but just to be sure you can use the files from the aforementioned issue:
- Not working (xlsx): https://github.com/PHPOffice/PhpSpreadsheet/files/14396742/alignment.xlsx
- Working (Xls): https://github.com/PHPOffice/PhpSpreadsheet/files/14396739/alignment.xls

About severity, I do not know if this should be considered a bug or just a cosmetic problem.

I'm reproducing the issue on Windows and doing the report from there. I found the original issue on Linux.

From https://github.com/PHPOffice/PhpSpreadsheet/issues/3918#issuecomment-1965387589 default's bold is correctly honored by LibreOffice.

I do not know if this ever worked and was not able to find any issue about this on https://bugs.documentfoundation.org/buglist.cgi?quicksearch=alignment%20xlsx.

Steps to Reproduce:
1. Download alignment.xslx from the GitHub issue: https://github.com/PHPOffice/PhpSpreadsheet/files/14396742/alignment.xlsx
2. Open it in LibreOffice Calc

Actual Results:
The text does not respect spreadsheet's defaults (see discussion in https://github.com/PHPOffice/PhpSpreadsheet/issues/3918)

Expected Results:
The text should respect spreadhseet's defaults


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 24.2.0.3 (X86_64) / LibreOffice Community
Build ID: da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1
CPU threads: 20; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: fr-FR (fr_FR); UI: fr-FR
Calc: CL threaded
Comment 1 guillaume.alabre 2024-02-26 23:17:06 UTC
Created attachment 192808 [details]
LibreOffice Calc does not respect spreadsheet's defaults
Comment 2 guillaume.alabre 2024-02-26 23:21:20 UTC
If the bug is not clear or anything else is required feel free to ask.

Thank you for this great application !
Comment 3 ady 2024-02-27 00:14:28 UTC
With all due respect, volunteers here would be forced to read and fully understand the report at:
 <https://github.com/PHPOffice/PhpSpreadsheet/issues/3918> 
in order to attempt to reproduce it.

We need clear steps to reproduce, what is the actual result, what is the expected result, and version information (LO menu help > about; click on the icon to copy to the clipboard).

From the pieces I gathered, apparently PHPOffice/PhpSpreadsheet generates an XLSX file with something like:
 <c r="A1" t="s">

and LO parses it in some "unexpected" way (according to 
 <https://github.com/PHPOffice/PhpSpreadsheet/issues/3918#issuecomment-1964743922> 
in terms of the resulting cell alignment, whereas for XLS (no last 'X'), the resulting alignment is "as expected".

Additionally, when the generated XLSX file includes an 's' parameter too:
 <c r="A1" t="s" s="0">
then apparently the resulting alignment recognized/parsed by LO Calc is "as expected".

I am not sure I understood this correctly, but maybe (and hopefully) this helps other users.
Comment 4 guillaume.alabre 2024-02-28 02:11:10 UTC
> We need clear steps to reproduce, what is the actual result, what is the expected result

I may not have been clear enough. The file I uploaded "alignment.xslx" should display with "horizontal center / vertical center / wrap", because those are the sheet's defaults. But the cell "A1" (in the file) is displaying "horizontal left / vertical bottom / no-wrap".

> and version information (LO menu help > about; click on the icon to copy to the clipboard).

The version is the one I pasted / selected in the dropdown: 24.2.0.3 (windows), and I just re-checked my version on linux which is 7.3.7.2 (linux) ant it exhibits the same behavior.

> From the pieces I gathered, apparently PHPOffice/PhpSpreadsheet generates an XLSX file with something like:
>  <c r="A1" t="s">
> and LO parses it in some "unexpected" way (according to 
>  <https://github.com/PHPOffice/PhpSpreadsheet/issues/3918#issuecomment-1964743922> 
> in terms of the resulting cell alignment

I did not want to introduce too much bias in case this was not the root issue. But in fact it looks like the default style for alignment is not applied with `<c r="A1" t="s">` while it is applied with `<c r="A1" t="s" s="0">`. Also the default "bold" style seems to be applied with `<c r="A1" t="s">` (without `s="0"`).
This kind on file is "correctly" displayed on Microsoft Excel (from the above GitHub issue) and as they are the only "source of truth" for this kind of file we have to believe this should be the correct behavior.

> whereas for XLS (no last 'X'), the resulting alignment is "as expected"

From my understanding this is an entirely different file format so it may not be fully comparable to xslx.
Comment 5 ady 2024-02-28 03:59:12 UTC
(In reply to guillaume.alabre from comment #4)

> I may not have been clear enough. The file I uploaded "alignment.xslx"
> should display with "horizontal center / vertical center / wrap", because
> those are the sheet's defaults. But the cell "A1" (in the file) is
> displaying "horizontal left / vertical bottom / no-wrap".

What do you mean with "those are the sheet's defaults"? The default for which software? FWIW, automatic wrap is not the default in LO Calc (and AFAICR, neither in Excel).

(As a side note, there are bugs in LO 24.2.0.3 regarding automatic wrap text, so this particular setting should rather not be checked against LO 24.2.0.3 in order to solve some potential incompatibility with the files generated by PHPOffice/PhpSpreadsheet.)
Comment 6 guillaume.alabre 2024-02-28 21:22:52 UTC
> What do you mean with "those are the sheet's defaults"? The default for which software? FWIW, automatic wrap is not the default in LO Calc (and AFAICR, neither in Excel).

I am not familiar with xlsx file format.

If I open the "alignment.xslx" file as zip and read the file in "xl/styles.xml" I can read the following:
```
<xf xfId="0" fontId="0" numFmtId="0" fillId="0" borderId="0" applyFont="0" applyNumberFormat="0" applyFill="0" applyBorder="0" applyAlignment="1"><alignment horizontal="center" vertical="center" textRotation="0" wrapText="true" shrinkToFit="false"/></xf>
```

So I guess this declares the default style for the spreadsheet.

> (As a side note, there are bugs in LO 24.2.0.3 regarding automatic wrap text, so this particular setting should rather not be checked against LO 24.2.0.3 in order to solve some potential incompatibility with the files generated by PHPOffice/PhpSpreadsheet.)

There is the same bug in LO 7.3.7.2 and it wraps correctly with "xls" format, so I'm not sure this is the same bug. I think that LO just don't apply spreadsheet's style by default.
Comment 7 ady 2024-02-29 00:04:23 UTC
(In reply to guillaume.alabre from comment #4)

> The file I uploaded "alignment.xslx"
> should display with "horizontal center / vertical center / wrap", because
> those are the sheet's defaults. But the cell "A1" (in the file) is
> displaying "horizontal left / vertical bottom / no-wrap".

Opening attachment 192808 [details] with 2 other spreadsheet tools, I indeed see "horizontal center / vertical center / wrap".

OTOH, with LO Calc (since 3.3 up to recent 24.8 alpha) and with AOO 4.1.15, I see "horizontal _default_ (so, "left" for the particular case with cell A1 containing text), vertical _bottom_, _no_ wrap text".

Setting this as inherited. Whether this should be considered a bug report or an enhancement request, I am not sure.
Comment 8 guillaume.alabre 2024-03-05 22:04:28 UTC
Created attachment 192986 [details]
xls files are correctly displayed

Here is an XLS version of the previous XSLX file, exported with the same tool.

Note that with this version the defaults (vertical_center, horizontal_center, wrap_text) are correctly applied.

This makes me think that the issue is more in how defaults are handled than a rendering issue.