Bug 159615 - Wrap text automatically works but does not save The wrap is gone when the file is opened XLSX
Summary: Wrap text automatically works but does not save The wrap is gone when the fi...
Status: RESOLVED DUPLICATE of bug 97106
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
(earliest affected) release
Hardware: All All
: medium normal
Assignee: Not Assigned
Keywords: filter:xls, filter:xlsx
Depends on:
Reported: 2024-02-07 08:32 UTC by ifbear
Modified: 2024-02-08 10:38 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:

File saved as Excel (8.79 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2024-02-08 10:09 UTC, ifbear
Example in Open Document format. (25.07 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-02-08 10:12 UTC, ifbear

Note You need to log in before you can comment on or make changes to this bug.
Description ifbear 2024-02-07 08:32:06 UTC
When using IF statements to display different text in a cell the “Wrap text automatically” works on the screen. But if I then save the spreadsheet , exit and then reopen the spreadsheet the alignment “ Wrap text automatically “ has gone. 

Cells with no IF statements so just plain text all work. These cells wrap automatically and stay wrapped when the spreadsheet is saved. 

Actual Results:
Actual result shows red arrow pointing to the right on the right hand side of the cell. The arrow disappeared if you widen the cell. 

Expected Results:
The alignment with the wrap text on works on screen. But once you save the file screen the alignment has gone and you get the red arrow indicating the cell is not wide enough. 

Reproducible: Always

User Profile Reset: No

Additional Info:
Version )x86_64 da48488a73ddd66ea24cf16bbc4f7b9c08e9bea1
Comment 1 m_a_riosv 2024-02-07 22:34:16 UTC
Please attach a sample file, reduce the size as much as possible without private information, and paste the information in Menu/Help/About LibreOffice, there is a copy icon.
Comment 2 Rafael Lima 2024-02-07 22:45:11 UTC
I can't reproduce this issue neither in 7.6 nor in 24.2.

However I'm not sure I could understand the bug correctly. A sample file would help a lot.
Comment 3 m_a_riosv 2024-02-07 23:07:05 UTC
(In reply to Rafael Lima from comment #2)
> I can't reproduce this issue neither in 7.6 nor in 24.2.
> However I'm not sure I could understand the bug correctly. A sample file
> would help a lot.

Right, we don't know what file format is used to save.
Comment 4 ifbear 2024-02-07 23:31:26 UTC
The spreadsheet is saved in .xlsx format. 

I will supply a cutdown version of my spreadsheet in the morning as an attachment

The text shown in the cell as a result of an if statement does not fit the cell width. So I use the format option to spreadsheet over 2 lines in the cell. This works as it formats correctly on screen. I then save the spreadsheet. 

Then switch off the computer. Next day I start the computer and open the spreadsheet. The formatting that has saved has gone and I have a red pointing arrow indicating that the text does not fit in the cell. 

I can reformat the cell to get the alignment correct. 

So I wonder should I use a different format to save the file? I can try this tomorrow and load up an example.
Comment 5 ifbear 2024-02-07 23:35:43 UTC
If I increase the column width the result of my IF statement will fit the text into the cell with no problem. 

If I save the file with the column width extra wide then this is saved and the text fits. 

I will attach an example in the morning. It’s nearly midnight here. Thanks.
Comment 6 ifbear 2024-02-08 00:06:27 UTC
I have learnt something. The issue I have does not occur if I save the file in Open document format. The issue is there if I save my file as an older style xlsx file format. 

I guess the older xlsx file format was not written to cope with such formatting. So it’s not a bug but a feature. I have created a 2 small worksheets that prove this.
Comment 7 ady 2024-02-08 00:34:28 UTC
Just a comment regarding the Wrap Text cell attribute, FWIW.

The Wrap Text changes the height of the cell, depending on the column width and the content (length) of the cell, *at the moment the Wrap Text attribute is applied*.

If the IF() function changes the result of the cell (depending on whichever condition), the height of the cell remains as it was at the time the WT was initially applied. IOW, changing the result of the cell (depending on the condition for the IF() function) will not _automatically_ recalculate the height.

Now, if you have a cell with text, and you manually edit the text and make it longer, then the cell's height can be extended; it might depend on others factors, especially related to the same row. OTOH, if you reduce the amount of text, the height of the cell is not automatically reduced. Setting Wrap Text OFF and then ON again on the cell, the height will be adapted again, according to the content of the cell at that moment.

Using IF() means that the cell is not being edited, but instead its result changes according to the condition for that IF(). This is not the same as editing the content of the cell.

In addition to this behavior, I believe that LO 24.2 improved/solved (at least partially) the behavior regarding Optimal Row Height and Optimal Column Width calculations. There are still things being improved for 24.2.1. Whether any of these changes might have some influence regarding Wrap Text behavior, IDK.

I am not saying what should happen. I am just describing the behavior in Calc.

Besides this behavior, there is the matter of whether the WT attribute is correctly saved as ods (or exported to xls(x) file format), which is the main question in this bug report.
Comment 8 ifbear 2024-02-08 10:09:15 UTC
Created attachment 192461 [details]
File saved as Excel

Here is the file saved as excel
Comment 9 ifbear 2024-02-08 10:12:19 UTC
Created attachment 192462 [details]
Example in Open Document format.

The format issue does not happen when the file is saved in an Open Doc format.
Comment 10 ady 2024-02-08 10:37:54 UTC
So, not in ods. This is about exporting (saving) as XLSX (or XLS).
Comment 11 ady 2024-02-08 10:38:30 UTC

*** This bug has been marked as a duplicate of bug 97106 ***