Issue 127672 - Xlsx with omitted cell references opens with empty cells
Summary: Xlsx with omitted cell references opens with empty cells
Status: RESOLVED FIXED
Alias: None
Product: Calc
Classification: Application
Component: open-import (show other issues)
Version: 4.1.5
Hardware: All All
: P3 Normal (vote)
Target Milestone: 4.1.14
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords: interop_OOXML
: 126344 128551 (view as issue list)
Depends on:
Blocks:
 
Reported: 2018-01-23 08:17 UTC by Alexander Korolev
Modified: 2023-01-09 15:46 UTC (History)
3 users (show)

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


Attachments
Example file with omitted cell references (6.89 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-01-23 08:17 UTC, Alexander Korolev
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Alexander Korolev 2018-01-23 08:17:30 UTC
Created attachment 86329 [details]
Example file with omitted cell references

See attached example. If I open this file in MS Excel, i see four cells filled by some data (A2, B2, A3 and B3). In OpenOffice Calc, only one cell (A2) has data, all others is empty.

In this xlsx package, the sheet data file (sheet1.xml) contains following fragment:

<sheetData>
  <row r="2" spans="1:2" ht="12.75">
    <c r="A2" s="1" t="s"><v>0</v></c>
    <c s="1" t="s"><v>1</v></c>
  </row>
  <row r="3" spans="1:2" ht="12.75">
    <c s="7"><v>42781</v></c>
    <c s="8" t="s"><v>2</v></c>
  </row>
</sheetData>

Standard ECMA-376 define attribute "r" of type "CT_Cell" as optional (see xsd schema, [Annex A.2 SpreadsheetML]).

MS Excel on cells with omitted references assumes that next cell has same row and increased column number from previous cell. A similar algorithm used for rows with omitted Row Index (also optional attribute "r" of <row> element).
Comment 1 damjan 2023-01-06 13:08:04 UTC
*** Issue 128551 has been marked as a duplicate of this issue. ***
Comment 2 damjan 2023-01-06 13:14:58 UTC
Confirming. Thank you for your bug report and sample file. This is a serious bug!! Elevating priority and setting milestone.

Luckily it should be pretty easy to fix. I think this method in main/oox/source/xls/sheetdatacontext.cxx has to change:

---snip---
    318 bool SheetDataContext::importCell( const AttributeList& rAttribs )
    319 {
    320     bool bValidAddr = mrAddressConv.convertToCellAddress( maCellData.maCellAddr, rAttribs.getString( XML_r, OUString() ), mnSheet, true );
    321     if( bValidAddr )
    322     {
    323         maCellData.mnCellType     = rAttribs.getToken( XML_t, XML_n );
    324         maCellData.mnXfId         = rAttribs.getInteger( XML_s, -1 );
    325         maCellData.mbShowPhonetic = rAttribs.getBool( XML_ph, false );
    326 
    327         // reset cell value, formula settings, and inline string
    328         maCellValue = OUString();
    329         mxInlineStr.reset();
    330         mbHasFormula = false;
    331 
    332         // update used area of the sheet
    333         extendUsedArea( maCellData.maCellAddr );
    334     }
    335     return bValidAddr;
    336 }
---snip---
Comment 3 damjan 2023-01-07 05:39:29 UTC
Fixed by commit 9c741048d2a06db94d9507ba978d3aecd557e7e9.

Resolving FIXED.

Alexander: thank you for your bug report, sample file, and excellent explanation of the problem!
Comment 4 Matthias Seidel 2023-01-07 10:53:22 UTC
Cherry-picked for AOO42X with:
https://github.com/apache/openoffice/commit/a60f0fbf670431e75ec883bbb8aa1ffb7dbe4cb4
Comment 5 damjan 2023-01-08 08:56:59 UTC
*** Issue 126344 has been marked as a duplicate of this issue. ***
Comment 6 Matthias Seidel 2023-01-09 15:46:03 UTC
Cherry-picked for AOO41X with:
https://github.com/apache/openoffice/commit/f4ffe9aeb04bfd08d8dd302a289902da8be99a95