Bug 158460 - FILESAVE XLS/X: "Wrap text automatically" setting is forced to export as ON when cell content has line breaks
Summary: FILESAVE XLS/X: "Wrap text automatically" setting is forced to export as ON w...
Status: RESOLVED NOTOURBUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:25.2.0
Keywords: filter:xls, filter:xlsx
: 97106 (view as bug list)
Depends on:
Blocks: Anchor-and-Text-Wrap XLSX-Limitations XLSX
  Show dependency treegraph
 
Reported: 2023-11-30 12:28 UTC by Shinji Enoki
Modified: 2024-12-25 10:39 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Excel: a cell with a line break with wrap disabled (51.92 KB, image/png)
2023-11-30 18:10 UTC, Mike Kaganski
Details
wrap-text.xlsx: Paris' unit test - the first three instances are not wrap-text (8.53 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2024-10-02 18:46 UTC, Justin L
Details
158460_multiline.ods: unresolvable puzzle for XLSX (15.52 KB, application/vnd.oasis.opendocument.spreadsheet)
2024-10-03 15:15 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shinji Enoki 2023-11-30 12:28:37 UTC
Description:
Export xlsx/xls with "Automatically wrap text" turned off for cells containing line breaks with Ctrl+Enter, and when you open it again, the wrapping setting is turned on.

Steps to Reproduce:
1.enter any text
2.Press Ctrl+Enter to break a line in the middle of text
3.Right click on that cell -> Format Cells -> Alignment tab
4.Make sure "Wrap text automatically" of Properties, is turned off
5.Export to xlsx or xls file
6.Open xlsx/xls file
7.Check "Wrap text automatically" setting

Actual Results:
"Wrap text automatically" setting is turned on

Expected Results:
"Wrap text automatically" setting is turned off


Reproducible: Always


User Profile Reset: No

Additional Info:
Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: en-US
Calc: threaded

I checked and reported based on the information in the Ask below:
https://ask.libreoffice.org/t/topic/98573
Comment 1 jun meguro 2023-11-30 12:30:52 UTC
Issue has been reproduced.
Comment 2 Saburo 2023-11-30 12:48:18 UTC
I reproduced it

Version: 7.6.3.2 (X86_64) / LibreOffice Community
Build ID: 29d686fea9f6705b262d369fede658f824154cc0
CPU threads: 12; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL threaded
Comment 3 ady 2023-11-30 13:00:50 UTC
Also repro with Latin fonts, so it is not related to CTL nor specific to Japanese fonts.

Saving as ods is fine.
Comment 4 ady 2023-11-30 17:48:31 UTC
There are several similar reports about exporting or saving the "wrap text automatically" cell attribute to either xlsx or to xls, but please note:

* a cell containing multiple lines ([CTRL]+[ENTER]), with wrap text ON, exports correctly;

* a cell containing multiple lines ([CTRL]+[ENTER]), with wrap text OFF, exports with wrap text ON.

IOW, a cell containing multiple lines (with each line introduced with [CTRL]+[ENTER] within the same cell) is _always_ exported with wrap text ON > BUG.

Also note that the way the text is displayed within the cell is not necessarily an indication of the status (ON/OFF) of the "wrap text automatically" attribute. You have to either check the cell properties or the status of the related icon on the toolbar.
Comment 5 Mike Kaganski 2023-11-30 18:10:09 UTC
Created attachment 191147 [details]
Excel: a cell with a line break with wrap disabled

I *suspect* that this is required in Excel: from a quick test, disabling wrap in a cell there merges the lines into a single line.

Code reading is necessary, but most likely this it NOTABUG / NOTOURBUG (because it's an external application limitation).
Comment 6 watanabe nobuo 2023-12-01 07:39:38 UTC Comment hidden (off-topic)
Comment 7 Mike Kaganski 2023-12-01 07:49:02 UTC Comment hidden (off-topic)
Comment 8 Justin L 2024-10-02 18:35:24 UTC
(In reply to Mike Kaganski from comment #5)
> I *suspect* that this is required in Excel: from a quick test, disabling
> wrap in a cell there merges the lines into a single line.
Calc 24.2 imports similarly with https://gerrit.libreoffice.org/c/core/+/156206

And in your example - if the user does any editing then Excel increases the row height.

(In reply to Shinji Enoki from comment #0)
> Export xlsx/xls with "Automatically wrap text" turned off for cells
> containing line breaks with Ctrl+Enter, and when you open it again, the
> wrapping setting is turned on.
True ever since the first LO 3.3.0 (when save as XLSX was introduced).

I assume this was "fixed" for XLSX in 24.2 with https://gerrit.libreoffice.org/c/core/+/155970, but I am in the process of reverting that (since with that patch cells formatted with "wrap text" were exported as without wrap enabled).
Comment 9 Justin L 2024-10-02 18:46:08 UTC
Created attachment 196854 [details]
wrap-text.xlsx: Paris' unit test - the first three instances are not wrap-text
Comment 10 Justin L 2024-10-02 19:22:31 UTC
(In reply to Justin L from comment #8)
> Calc 24.2 imports XLSX similarly with
and XLS imports a round-tripped wrap-text.xls as a single line in 7.6.x from
commit b224e450d09a0405043a011d48f4f57e88cdc344
Author: Henry Castro on Tue Feb 28 09:50:28 2023 -0400
    sc: filter: excel: import cell multi-line text
    
    The excel document, if the cell has multi-line text and
    the property wrap text is off, the paragraphs are rendered
    all in a single line.
Comment 11 Justin L 2024-10-03 15:15:20 UTC
Created attachment 196868 [details]
158460_multiline.ods: unresolvable puzzle for XLSX

Whoever thinks they can fix this bug needs to wrestle with the implications of 158460_multiline.ods. When a user interacts with LO (creating new content for example) then they can see in their newly modified XLSX document what is seen in this ODS file.

The fact that Excel simply cannot have both newlines and out-flowing text is proof to me that "the way Excel does things" is broken, and the fact that we started to copy this broken behaviour on import in 24.2 is just wrong.

Thus, the most correct way to handle this is the way we have already been doing it - to export any multiline content as wrap-enabled (since LO will never create multiline content on only one line).

The ONLY time when we can export multiline without wrap-text is if we know we are DISPLAYING it in only one line.
Comment 12 Justin L 2024-10-03 18:44:35 UTC
proposed export fix (for the new case where we copy Excel's buggy behaviour and import newlined content as if it was a single line) at https://gerrit.libreoffice.org/c/core/+/174436
Comment 13 Justin L 2024-10-04 11:57:43 UTC
*** Bug 97106 has been marked as a duplicate of this bug. ***
Comment 14 Commit Notification 2024-10-19 15:30:50 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/424329bb0b71fdb46b56be5638d5304dbef9e718

tdf#158460 xls/x export: don't force wrap-text for imported single-line

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 15 Justin L 2024-10-19 15:43:04 UTC
Based on mk's comment 5 (confirmed in comment 11), I will mark this as NOTOURBUG. (I'm not marking as fixed, since comment 14 resolves a new 7.6-ish situation while other situations pre-date 7.6.)

It is an XLS/XLSX format limitation. We should be round-tripping OK at this point.