You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/03/16 16:10:42 UTC

[Bug 56274] New: SXSSF produces corrupt xlsx file from valid xlsx template

https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

            Bug ID: 56274
           Summary: SXSSF produces corrupt xlsx file from valid xlsx
                    template
           Product: POI
           Version: 3.10
          Hardware: PC
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: SXSSF
          Assignee: dev@poi.apache.org
          Reporter: yaniv@kundas.net

Created attachment 31393
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31393&action=edit
Sample input file exhibiting the problem

Upgrading from poi-3.9 to poi-3.10 caused a bug where xlsx files loaded as a
template using XSSF, added with some data and written with SXSSF resulted in
corrupt files.

Opening the resulting files with Excel 2013 results in the following Yes/No
dialog:
"We found a problem with some content in 'Filename.xlsx'. Do you want us to try
to recover as much as we can? If you trust the source of this workbook, click
Yes."
Clicking yes shows the recovery result dialog, with a list of repaired
table*.xml files under /xl/tables in the internal excel structure.

Attached is a sample input xlsx file exhibiting the problem, which can be
reproduced by the following reduced test:

public static void main(String[] args) throws Exception {
    File inputFile = new File("ExecutiveReportTemplate.xlsx");
    File outputFile = new File("ExecutiveReportTemplate-new.xlsx");
    XSSFWorkbook inputWorkbook = new XSSFWorkbook(new
FileInputStream(inputFile));
    SXSSFWorkbook outputWorkbook = new SXSSFWorkbook(inputWorkbook);
    outputWorkbook.write(new FileOutputStream(outputFile));
}

I examined the internal xml files, and the differences seem to be in the
/xl/tables/table*.xml files -
The tableColumn elements have the same id and dataDxfId attributes, but
different name attributes:
in poi-3.9 the name attributes correspond to the order of the columns in the
template worksheet,
in poi-3.10 the name attributes seem to be out-of-order, and one of the columns
have a duplicate name.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

--- Comment #5 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31605
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31605&action=edit
Unit test for bug #56274

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

--- Comment #4 from Nick Burch <ap...@gagravarr.org> ---
Thanks for this updated patch

Is there any chance you could write a short unit test, which triggers the
problem on 3.10, and shows it's fixed with the patch applied? That way, we can
be sure it's solved, and also be sure it remains fixed into the future!

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Yaniv Kunda <ya...@kundas.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #31393|0                           |1
        is obsolete|                            |

--- Comment #6 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31606
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31606&action=edit
Sample input file exhibiting the problem (required by unit test)

This is the sample input file for the attached unit test -
it should be placed in the /test-data/spreadsheet/ directory of the
distribution

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
I tried to take a look, but unfortunately your patch changes lots of
whitespaces and other unrelated things like imports and thus is hard to apply
cleanly.

Any chance you can produce a minimal patch with only the actually required
changes? This will make it easier for others to review/apply the patch.

Thanks!

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

--- Comment #1 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31403
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31403&action=edit
Patch for fixing the bug

I've located the bug XSSFTable.updateHeaders(), where the xmlFragment id is
used as a cellnum - which will only be the same in the special case of adding
columns to a sheet one by one, in order; inserting/moving columns will create
xmlFragment ids not consistent with cell numbers.

I have fixed it by using a counter (starting from firstHeaderColumn) that
advances along the table columns, and then used to fetch sheet cells by their
actual cellnum.

The additional minor optimizations are not related, but I deemed them
appropriate while reviewing XSSFTable - if a commiter wishes to discard them
for the purpose of fixing this bug, then only the changes in the
updateHeaders() method should be included.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Nick Burch <ap...@gagravarr.org> ---
Thanks, patch and unit test applied in r1596624.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Yaniv Kunda <ya...@kundas.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #31403|0                           |1
        is obsolete|                            |

--- Comment #3 from Yaniv Kunda <ya...@kundas.net> ---
Created attachment 31564
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31564&action=edit
Patch for fixing the bug

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 56274] SXSSF produces corrupt xlsx file from valid xlsx template

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56274

Yaniv Kunda <ya...@kundas.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #31403|Patch for fixing the bug    |Patch for fixing the bug
        description|                            |(and other minor
                   |                            |optimizations)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org