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 2017/11/22 13:33:09 UTC
[Bug 61798] New: Corrupted Excel file produced due to wrong
dimension calculation during XSSFWorkbook.write(str) call
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
Bug ID: 61798
Summary: Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Product: POI
Version: 3.17-FINAL
Hardware: PC
Status: NEW
Severity: major
Priority: P2
Component: XSSF
Assignee: dev@poi.apache.org
Reporter: marek.zaplata@gmail.com
Target Milestone: ---
Created attachment 35546
--> https://bz.apache.org/bugzilla/attachment.cgi?id=35546&action=edit
Corrupted file generated by JUnit test attached
Fix introduced for bug 53611 is causing another bug which produce a corrupted
Excel file.
POI will generate corrupted file if dimension end column will be the last
possible column (number 16384 /column XFD/).
Dimension calculation algorithm introduced in revision:
https://svn.apache.org/viewvc?view=revision&revision=1767096
has a bug, which sets dimention end cell value too big (+1 column).
This bug will lead to corrupted file when last cell will be in use.
Following test:
https://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?r1=1767096&r2=1767095&pathrev=1767096
has wrong assertion. Cell number 7 is H (not I) column.
Test code to easy reproduce this bug (corrupted Excel file):
@Test
public void test53611_bug() throws IOException {
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("test");
Row row = sheet.createRow(1);
Cell cell = row.createCell(1);
cell.setCellValue("blabla");
row = sheet.createRow(4);
// Allowable column range for EXCEL2007 is (0..16383) or ('A'..'XDF')
cell = row.createCell(16383);
cell.setCellValue("blabla");
// we currently only populate the dimension during writing out
// to avoid having to iterate all rows/cells in each add/remove of a row or
cell
//OutputStream str = new FileOutputStream("/tmp/53611_bug.xlsx");
OutputStream str = new ByteArrayOutputStream();
try {
wb.write(str);
} finally {
str.close();
}
// Expected :B2:XFD5
// Actual :B2:XFE5 <-- which is out of Excel range. This will
produce corrupted Excel file
assertEquals("B2:XFD5",
((XSSFSheet)sheet).getCTWorksheet().getDimension().getRef());
wb.close();
}
Corrupted file generated by this test also attached.
--
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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
Jan Peter Stotz <jp...@gmx.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jpstotz@gmx.de
--- Comment #4 from Jan Peter Stotz <jp...@gmx.de> ---
*** Bug 62490 has been marked as a duplicate of this 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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
--- Comment #2 from dolphin.in.the.sky.51@gmail.com ---
I made a mistake in patch code.
not "row.getFirstCellNum()"
Correctly,"row.getLastCellNum()"
Sorry.
--
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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Dominik Stadler <do...@gmx.at> ---
Fixed with r1819404, now the dimension should be calculated correctly.
--
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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |richard.evans@blueallegro.n
| |et
--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
*** Bug 62673 has been marked as a duplicate of this 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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
dolphin.in.the.sky.51@gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dolphin.in.the.sky.51@gmail
| |.com
OS| |All
--- Comment #1 from dolphin.in.the.sky.51@gmail.com ---
Excuse my poor English.
I am applying the patch of the following contents.
in org.apache.xssf.usermodel.XSSFSheet
protected write(OutputStream out) throws IOException {
...
// then calculate min/max cell-numbers for the worksheet-dimension
if(row.getFirstCellNum() != -1) {
// maxCell = Math.min(maxCell, row.getLastCellNum());
maxCell = Math.min(maxCell, row.getLastCellNum()-1);
}
Row.getLastCellNum() is return the index of the last cell contained in this row
PLUS ONE.
I would be pleased if it will be helpful.
--
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 61798] Corrupted Excel file produced due to wrong dimension
calculation during XSSFWorkbook.write(str) call
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=61798
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Depends on| |53611
Referenced Bugs:
https://bz.apache.org/bugzilla/show_bug.cgi?id=53611
[Bug 53611] Incorret dimension set in created workbook sheet xml file
--
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