Issue 81233 - MS Excel 2003 SpreadsheetML import corrupts references to columns that are multiples of 26 (eg. Z)
Summary: MS Excel 2003 SpreadsheetML import corrupts references to columns that are mu...
Status: RESOLVED FIXED
Alias: None
Product: Calc
Classification: Application
Component: open-import (show other issues)
Version: OOo 2.2.1
Hardware: PC All
: P3 Trivial with 2 votes (vote)
Target Milestone: 4.1.14
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
: 86486 90108 (view as issue list)
Depends on:
Blocks:
 
Reported: 2007-09-03 16:27 UTC by rolik
Modified: 2023-03-01 13:37 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---


Attachments
simple example (4.00 KB, text/xml)
2007-09-03 16:40 UTC, rolik
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description rolik 2007-09-03 16:27:41 UTC
Hello (I am from Russia, sorry for my bad English)!
I have trouble with import from XML (format MS Excel 2003) to OpenOffice Calc.

See example (some information from XML code):
*************
 I have 2 formulas with relative position:  R[-1]C.
 If I open its by MS Excel, I see that formulas have absolute positions:  Y5 and
Z5  - It’s correct.
 If I open its by OpenOffice, I see that formulas have absolute positions: Y5
and  A5 - It’s WRONG!  (OpenOffie skipped column Z when translating relative
position to absolute position).
*************

I have trouble with column Z, when I using relative position into XML.
With other columns I haven’t trouble.
Comment 1 rolik 2007-09-03 16:40:41 UTC
Created attachment 47930 [details]
simple example
Comment 2 frank 2007-09-03 20:25:56 UTC
Not a P1 Issue lowered to P4
Comment 3 frank 2007-09-04 08:34:31 UTC
Hi Swante,

seems to be yours.

Frank
Comment 4 svante.schubert 2007-09-04 10:41:31 UTC
Thanks for the issue, rolik.

Nevertheless I really need help on this Excel 2003 XML / spreadsheetml filter,
as there are I am distracted by many other projects and see no possibility to
fix this in the short distance..
Comment 5 krishna_36 2010-08-08 06:07:19 UTC
Is there any resolution for this issue.
Comment 6 alex6684 2010-08-14 18:49:59 UTC
In http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=33060 we 
found a possible solution for OOo version 3.2.1 (OOO320m18, build 9502) by 
applying two changes in
"C:\Program Files\OpenOffice.org 3
\Basis\share\xslt\import\spreadsheetml\spreadsheetml2ooo.xsl"

Replace "floor( $column-number div 26 )" by "floor( ($column-number - 1) div 
26 )"
and "$column-number mod 26" by "($column-number - 1) mod 26 + 1"

With these changes, the problem seems to have disappeared.
Comment 7 krishna_36 2010-08-14 19:22:19 UTC
Hi That post was raised by me.

The solution is fine and as suggested would work uptill 702 column number only.

would this be taken up in the next release or a next patch ?
Comment 8 alex6684 2010-08-14 20:10:32 UTC
The original code has the same limitation to 702 columns. But the MS Excel 2003 
XML format is limited to 256 columns so that should be no problem.
Comment 9 krishna_36 2010-08-14 20:12:53 UTC
But i did not find that limitation. Used MS office 2007 to open the xml files 
did not find any limitation
Comment 10 damjan 2023-01-11 18:28:20 UTC
Fixed by the below commit, resolving FIXED.

Thank you alex6684 for your brilliant investigation, and thank you everyone for your bug report, sample file, testing and comments :-).


commit 577fe17932e0dec38662067d1a86e7fd6ae525b6
Author: Damjan Jovanovic
Date:   Wed Jan 11 19:47:12 2023 +0200

Our XSLT-based MS Office 2003 SpreadsheetML format import filter, when doing
conversion from R1C1 style column references to our A1 style references, had a
bug where it was treating the column value as 0-based, and dividing by 26 to
find the 1st letter and taking the remainder when divided by 26 for the second
letter. Those numbers are then each converted to a letter [0 = nothing,
1 = "A", 2 = "B", ..., 26 = "Z"].

However since R1C1 is 1-based, and not 0-based, this breaks for column numbers
which are multiples of 26, as 26 mod 26 = 0, so the least significant digit is
converted to nothing while the most significant digit gets incremented too
early.

Fix this by converting the column number to 0-based by subtracting 1 before
calculation, then adding 1 to the least significant digit afterwards.

Also the fact we have 2 letters limited us to a maximum of 26^2 = 676 columns,
after which column references would wrap around. Fix this too, by adding a 3rd
letter, which lets us address a maximum of 17576 columns.

Add a sample file to our unit tests.

Found by: alex dot plantema at xs4all dot nl
Patch by: me

M       main/filter/source/xslt/import/spreadsheetml/spreadsheetml2ooo.xsl
A       test/testuno/data/uno/sc/fvt/Bug81233ColumnZReference.xml
M       test/testuno/source/fvt/uno/sc/formula/TestFormulaDocs.java
Comment 11 damjan 2023-01-11 18:32:26 UTC
*** Issue 90108 has been marked as a duplicate of this issue. ***
Comment 12 damjan 2023-02-01 15:56:39 UTC
*** Issue 86486 has been marked as a duplicate of this issue. ***
Comment 13 damjan 2023-02-07 17:59:42 UTC
Cherry-picking for AOO41X in commit 0285e67f3b672422a011fcc082697d769fcf7d81.
Comment 14 Matthias Seidel 2023-02-07 18:06:30 UTC
Has this already been cherry-picked for AOO42X?
Comment 15 damjan 2023-02-07 18:10:29 UTC
(In reply to Matthias Seidel from comment #14)
> Has this already been cherry-picked for AOO42X?

No it hasn't.

What is meant to be process for using "Target Milestone" vs "Flags" vs the "release_blocker" Keyword?
Comment 16 Matthias Seidel 2023-02-07 18:19:40 UTC
As I understand it the "Target Milestone" is the version for which the issue will be closed.

A "release blocker" is an issue that blocks the release of a certain version if not fixed.

Normally, I would cherry-pick for AOO42X and then if it fits to AOO41X, since that is the version we will release next.
Comment 17 damjan 2023-02-07 18:25:29 UTC
(In reply to Matthias Seidel from comment #16)
> As I understand it the "Target Milestone" is the version for which the issue
> will be closed.
> 
> A "release blocker" is an issue that blocks the release of a certain version
> if not fixed.
> 
> Normally, I would cherry-pick for AOO42X and then if it fits to AOO41X,
> since that is the version we will release next.

Alright thank you.

And we track which branches the commit has been cherry-picked to by means of comments like "Cherry-picked for <branch> with <commit/URL>"?
Comment 18 Matthias Seidel 2023-02-07 18:29:56 UTC
At least that's the way I do it.
Comment 19 Matthias Seidel 2023-02-07 18:45:20 UTC
(In reply to damjan from comment #17)
> And we track which branches the commit has been cherry-picked to by means of
> comments like "Cherry-picked for <branch> with <commit/URL>"?

Back then, when we used Subversion, we had a mechanism, that did this automatically when you mentioned the issue number in your commit.
Comment 20 Marcus 2023-02-07 19:47:29 UTC
An addition:

You can set the flag "release_blocker" with a "?" as value when you think that the fix is OK  to be part of the respective release, e.g., when the changed code is not much like a few lines and / or it's easy to test.

However, at the end the release manager decides if so.
Comment 21 Matthias Seidel 2023-02-08 15:00:31 UTC
So this is fixed in AOO41X but not in AOO42X.

We must not forget to cherry-pick it.

For the moment, I will set it as "Target Milestone" 4.1.14.
Comment 22 damjan 2023-02-08 18:14:53 UTC
Cherry-picked for AOO42X with 0f570a5492b9ec8bf48d122b191318403f88eed0.
Comment 23 alex6684 2023-03-01 12:52:15 UTC
In the new version references to columns 677 to 702 don't work.
What's the purpose of applying FLOOR to the result of a MOD operation?
Please delete my e-mail address from comment 10.

Here's a way to obtain the column characters, not limited to 3, in pseudocode:

columncharacters := "";
while columnnumber > 0 do
  columncharacters := concat (chr ((columnnumber - 1) mod 26) + 65; columncharacters);
  columnnumber := floor ((columnnumber - 1) div 26)
end;

(Then add $ for absolute references.)
Comment 24 alex6684 2023-03-01 13:37:38 UTC
(In reply to alex6684 from comment #23)

Here's the correct version:

columncharacters := "";
while columnnumber > 0 do
  columncharacters := concat (chr ((columnnumber - 1) mod 26 + 65); columncharacters);
  columnnumber := floor ((columnnumber - 1) div 26)
end;