After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 356711 - Avoid synthesizing duplicate styles when saving multi-line text in Excel format
Avoid synthesizing duplicate styles when saving multi-line text in Excel format
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export MS Excel (tm)
git master
Other Linux
: Low enhancement
: ---
Assigned To: Jody Goldberg
Jody Goldberg
: 530703 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-09-19 11:53 UTC by P. K. CHAN, Esq.
Modified: 2011-08-21 18:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch to gnumeric (1.45 KB, patch)
2011-08-19 21:45 UTC, Andreas J. Guelzow
none Details | Review
updated patch (1.66 KB, patch)
2011-08-19 23:40 UTC, Andreas J. Guelzow
none Details | Review

Description P. K. CHAN, Esq. 2006-09-19 11:53:55 UTC
Steps to reproduce:

i.  In Gnumeric 1.6.3 on Ubuntu Dapper (unable to test in Windows due to bug #311354), create a multi-line text in cell A1, say, ab<Alt>+<Enter>cd.
ii.  Save the file as MS Excel 97 format, then open the same file in MS Excel.

Actual result:

A1 displayed as "abcd".  However, when in edit mode or when observed in formula bar, A1 is displayed as "ab<line break>cd".

Expected result:

A1 displayed as "ab<line break>cd".
Comment 1 Jon Kåre Hellan 2006-10-27 08:10:27 UTC
Confirmed with CVS and Excel 2003
Comment 2 Jon Kåre Hellan 2006-10-28 09:13:55 UTC
We need to turn on word wrap in the format.
Comment 3 A 2007-01-10 00:27:49 UTC
i confirm this on windows xp and gnumeric 1.7.6 and XL 2000, I would imagine its just the difference between linux style and windows style line breaks showing itself...
Comment 4 A 2007-01-10 00:36:55 UTC
upon further testing, i find excel will fix it if you click in the formula edit gizmo and  then back on the main spreadsheet, this fix seems to be permanent for the file.
Comment 5 Andreas J. Guelzow 2009-06-25 06:34:16 UTC
*** Bug 530703 has been marked as a duplicate of this bug. ***
Comment 6 Andreas J. Guelzow 2010-07-01 03:52:53 UTC
hmm, this should be easy to fix for anybody who can test with excel....
Comment 7 Valek Filippov 2011-08-19 00:34:45 UTC
I've checked file saved from gnumeric with the same file re-saved from XL.
For multi-line cells XL sets 'fWrap' bit in XF record ('wrap_text' in our BiffXFData struct). By changing it in hexeditor I was able to produce 'correct' file from one saved by gnumeric.
Comment 8 Andreas J. Guelzow 2011-08-19 05:46:41 UTC
@Valek:

Does this mean that whenever there is a newline used in xls, wraptext must be switched on? And so if I use a long string with a single newline, then the text will even wrap elsewhere?
Comment 9 Andreas J. Guelzow 2011-08-19 05:50:26 UTC
To be more precise:
in Gnumeric we can have:

Hello World this is a long text
in a small cell

in a small cell, so that the text runs over the cells to the right and is shown in two lines only (since there is a newline after "text")

If I switch on wrap-text it is shown as:

Hello
World
this is a
long text
in a
small cell

although there is still only one inserted newline.


So in Excel there first is not possible?
Comment 10 Andreas J. Guelzow 2011-08-19 21:45:04 UTC
Created attachment 194269 [details] [review]
proposed patch to gnumeric

patch that sets the wrap text flag when exporting a cell with newlines in the type text.
Comment 11 Andreas J. Guelzow 2011-08-19 23:40:43 UTC
Created attachment 194274 [details] [review]
updated patch
Comment 12 Valek Filippov 2011-08-20 01:08:38 UTC
Andreas, patch from comment #11 works here.
XL displays "ab<CR>cdef" in A1 as two lines "ab" and "cdef", which I believe is expected result.
Comment 13 Andreas J. Guelzow 2011-08-20 06:10:07 UTC
Valek, I have made another change to the patch before committing it. Would you please verify that the committed version in fat fixes the problem. (The change consists of not synthesizing another style if wrap-text should already be set.)

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 14 Valek Filippov 2011-08-20 17:15:46 UTC
Andreas, committed patch works here in part related to line wrapping.

I'm not quite sure how to verify that additional style is not synthesised.
I tested with wrapped lines
- regular without 'wrap text' set in A1,
- regular with 'wrap text' set in A2,
- bold with 'wrap text' set in A3,
- bold w/o 'wrap text' set in A4 to A7.

Resulting file has additional XFs for cells which have to be wrapped and have no 'wrap text' set. However cells refer to only three XFs (two of the referred styles are the same 'bold, wrap', 3rd is 'regular, wrap').

I don't know if it's worth efforts to optimise gnumeric to search for same XF before synthesising a new one (each XF record is 24 bytes in size).
Open/save cycle optimises it automatically, because gnumeric reads 'wrap text' for all lines with 0x0a and on saving do not synthesise additional styles.
Comment 15 Andreas J. Guelzow 2011-08-20 18:07:37 UTC
Thanks Valek. my comment about what I changed was just intended as information. The verification was intended with regard to the original problem. Nevertheless it is interesting that you noted that we create duplicate styles. We really should check on that. This could create unnecessarily large xls files when saving a .gnumeric or .odf file.

I am reopening and retitling.
Comment 16 Andreas J. Guelzow 2011-08-21 17:23:34 UTC
We are now synthesizing each style only once. We may still end up with duplicates if we have an existing style with wrap-text and synthesize a new one, but we should have no duplication between all the synthesized ones.



This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Comment 17 Valek Filippov 2011-08-21 18:10:52 UTC
Confirmed. Seems to be one redundant XF per style in case I have same style cells with and w/o 'wrap_text'.
It also seems to store 'original' styles of the cells for which new XFs were synthesised.