Bug 98074 - FILESAVE: Cell formatting lost / corrupted style.xml (reported by Excel) when saving file to XLSX
Summary: FILESAVE: Cell formatting lost / corrupted style.xml (reported by Excel) when...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium major
Assignee: Markus Mohrhard
URL:
Whiteboard: target:6.2.0 target:6.1.1
Keywords: filter:xlsx
Depends on:
Blocks: XLSX-Corrupted
  Show dependency treegraph
 
Reported: 2016-02-22 07:07 UTC by Kevin Suo
Modified: 2018-07-26 00:10 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
test xlsx file (21.15 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2016-02-22 07:07 UTC, Kevin Suo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Suo 2016-02-22 07:07:33 UTC
Created attachment 122861 [details]
test xlsx file

Steps:
1. Open the attached xlsx file with Calc.
2. Save as another xlsx file.
--> Cell background color lost.

No bug when save as .ods or .xls.

Version: 5.0.5.2
Build ID: 55b006a02d247b5f7215fc6ea0fde844b30035b3
Locale: zh-CN (zh_CN)

Version: 5.1.1.1 (x64)
Build ID: c43cb650e9c145b181321ea547d38296db70f36e
CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; 
Locale: zh-CN (zh_CN)
Comment 1 Kevin Suo 2016-02-22 07:55:45 UTC
Actually it seems that all cell formatting is lost: percentage numebr format, background, decimal places etc.

Using the following bibisect repo:
https://gerrit.libreoffice.org/#/admin/projects/bibisect-win32-5.1
I can reproduce in the "oldest" build:
Version: 5.0.0.0.alpha1+
Build ID: ab465b90f6c6da5595393a0ba73f33a1e71a2b65
Comment 2 Kevin Suo 2016-02-22 08:05:00 UTC
When open the resaved xlsx file with MSO, it says the style.xml contains invalid characters at line 2 column 316266.

Then I open the style.xml with text editor and found it does contains invalid characters:
<cellStyle name="<GARBAGE CHAR>" xfId="452" builtinId="53" customBuiltin="true"/>
Comment 3 Kevin Suo 2016-02-22 08:11:23 UTC
(In reply to Kevin Suo from comment #2)

MORE INFO:

When open my test xlsx file in Calc, there is a style with garbage characters in its name.
Delete this style and then resave, the bug is gone.
So the issue is related to the handling of this style name at the time when resave as xlsx file.
Remember, bug does not exist when save as other formats.
Comment 4 m.a.riosv 2016-02-24 03:12:43 UTC
Hi Kevin,

seems the issue is related with a strange style '?痃%S&F??o', deleting it the save it's fine for me, and a lot of other styles disappear.
Maybe there is some kind of corruption in the file.
Comment 5 Kevin Suo 2016-02-24 04:00:18 UTC
(In reply to m.a.riosv from comment #4)
Yes, I already noted this style issue, but in my opinion this is still a bug of the XLS filter, as the formatting loss does not happen when resave as other formats.

From the style.xml we can find that this strange style althrough defined, it was not used in the cells which lose their formatting when resave as xls format.
Comment 6 m.a.riosv 2016-02-24 23:26:43 UTC
I have not Excel to verify, but even Aoo has troubles with styles opening the file.

Using zamzar to convert the file from xlsx to ods, the same strange styles are there
Comment 7 raal 2016-02-25 16:50:24 UTC
I can confirm with Version: 5.2.0.0.alpha0+
Build ID: ef02de2698d90fd874bddf3146165cbe85487bc5
CPU Threads: 1; OS Version: Windows 6.1; UI Render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2016-02-19_23:40:50

and 4.2.8.2

When open the resaved xlsx file with MSO, it says the style.xml contains invalid characters at line 2 column 316266. -  I can confirm with excel 2010. I can open original file in excel without problem.
Comment 8 Kevin Suo 2017-01-09 03:46:06 UTC
Bug exists in the old LibreOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4 linux. 

Set platform to ALL, version to 3.3.0 release.
Comment 9 Commit Notification 2018-07-22 02:18:33 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=fa881095bc62c3646406c82a98d8503377288a54

tdf#98074, using the same builtinId maps the styles to the same one

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 10 Commit Notification 2018-07-26 00:10:37 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f67c6912e8612c5850a5728c2222971b4ec130b9&h=libreoffice-6-1

tdf#98074, using the same builtinId maps the styles to the same one

It will be available in 6.1.1.

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

Affected users are encouraged to test the fix and report feedback.