GNOME Bugzilla – Bug 511135
weird behavior of xls files with non ascii characters on loading
Last modified: 2011-08-10 21:16:51 UTC
If an xls file contains a formula resulting in a string containing at least one non-ascii character, an extra charater is added when loading. Pressing F9 removes the extra character.
Created attachment 103371 [details] a simple file showing the issue
What made that file? Gnumeric or something else?
It seems we are confusing character length and byte length somehow here. Feuille1!A1 = xf(0x15) = style (0x9b4ba8) [LEN = 10] Opcode: 0x6 Feuille1!A2 = xf(0x15) = style (0x9b4ba8) [LEN = 27] Formula in Feuille1!A2 has recalc tag 0x0; String len 2, byte length 5: UTF16 : 0 | 01 e9 00 d7 00 XX XX XX XX XX XX XX XX XX XX XX | .....*********** Opcode: 0xd7 Notice that the string we see seems to include the next opcode.
The file was made with gnumeric
The problem is on the write side, not the read side. I do not understand why we need "output_len++;" here. if (flags & STR_LEN_IN_BYTES) output_len = out_bytes - offset; else { if (byte_len > 0) output_len = g_utf8_pointer_to_offset (txt, in_bytes); else output_len = char_len; output_len++; }
Created attachment 103792 [details] [review] Proposed patch Jean, please try this patch. I do not see any ill effect in my 30s of testing. Note: you will have to resave the file.
It works, thanks.
Jean, could you produce a non-ascii test sheet? One that exercises non-ascii anywhere you can think of. * Sheet names * Range names * Formula * Cells with strings * Cells with string result * Cells with rich text * String constants as part of formulas * Page headers * Graphs * ... Thanks
Created attachment 103830 [details] sample file Morten, is this what you want?
Precisely. Thanks. Saving as xls and loading the result, I get the barfage below. And something is wrong with cell A6 (rich text). (lt-gnumeric:20573): gnumeric:read_expr-WARNING **: EXCEL : Unhandled PTG 0x0. formula data : (shared) 0 | 00 00 00 00 c0 18 00 XX XX XX XX XX XX XX XX XX | .......********* (lt-gnumeric:20573): gnumeric:read_expr-WARNING **: A1 : Unknown Formula/Array
Saving fixes. Keeping open for issues in comment #10.
No warnings. A6 looks like gnumeric (combination of super/subscript and bold/italic). Could be closed?
Hmm, the original file still has one issue, cell A2 contains "=A1" but nothing is displayed there until F9 is pressed.
@Jean this looks like a problem with the file. If you recalculate and resave the file as xls, then opening the new file will show that cell content.
It doesn't for me
Jean, did you "_recalculate_ and resave"?
Hmm, probably missed a step. Things seem to work.
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.