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 2022/01/11 15:22:08 UTC
[Bug 65798] New: When reading Excel files created using SXSSFWorkbook, SheetContentsHandler cell method is getting incorrect formattedValue
https://bz.apache.org/bugzilla/show_bug.cgi?id=65798
Bug ID: 65798
Summary: When reading Excel files created using SXSSFWorkbook,
SheetContentsHandler cell method is getting incorrect
formattedValue
Product: POI
Version: 5.1.0-FINAL
Hardware: Macintosh
OS: Mac OS X 10.1
Status: NEW
Severity: regression
Priority: P2
Component: SXSSF
Assignee: dev@poi.apache.org
Reporter: jairam.m@gmail.com
Target Milestone: ---
I am using SXSSFWorkbook to create large Excel files and the Excel file has a
mix of the STRING & NUMERIC cells. When reading these files back, for the
STRING cell following a NUMERIC cell, in the SheetContentsHandler cell method
the formattedValue is received as the concatenated value of the previous and
current cells. This issue is not observed for all other cells.
The same issue is not happening if the files are created using XSSFWorkbook.
This issue is observed only in the latest Apache POI 5.1.0 version, this issue
did not exist in the previous versions of the library.
Sample code snippet & logs.
public class SampleSheetContentHandler implements SheetContentsHandler {
@Override
public void startRow(int rowNum) {
}
@Override
public void endRow(int rowNum) {
}
@Override
public void cell(String cellReference, String formattedValue, XSSFComment
comment) {
System.out.println("formattedValue --> " + formattedValue);
}
@Override
public void headerFooter(String arg0, boolean arg1, String arg2) {
}
}
SXSSFWorkbook:
// CREATE EXCEL SXSSFWorkbook
SXSSFWorkbook wb = new SXSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream(new File(filePath));
Sheet sheet = wb.createSheet("TEST");
Row row = sheet.createRow(0);
Cell cell = row.createCell(0, CellType.NUMERIC);
cell.setCellValue(0);
cell = row.createCell(1, CellType.STRING);
cell.setCellValue("String 1");
cell = row.createCell(2, CellType.STRING);
cell.setCellValue("String 2");
wb.write(fileOut);
fileOut.close();
wb.close();
wb.dispose();
When reading the file created with above code snippet using SXSSFWorkbook, I am
observing incorrect values in the cell method of SampleSheetContentHandler, the
value for the STRING cell is received as 0.0String 1 instead of String 1
formattedValue --> 0
formattedValue --> 0.0String 1
formattedValue --> String 2
XSSFWorkbook:
// CREATE EXCEL XSSFWorkbook
XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
fileOut = new FileOutputStream(new File(filePath));
sheet = xssfWorkbook.createSheet("TEST");
row = sheet.createRow(0);
cell = row.createCell(0, CellType.NUMERIC);
cell.setCellValue(0);
cell = row.createCell(1, CellType.STRING);
cell.setCellValue("String 1");
cell = row.createCell(2, CellType.STRING);
cell.setCellValue("String 2");
xssfWorkbook.write(fileOut);
fileOut.close();
xssfWorkbook.close();
When reading the file created with above code snippet using XSSFWorkbook, I am
observing correct values in the cell method of SampleSheetContentHandler
formattedValue --> 0
formattedValue --> String 1
formattedValue --> String 2
--
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 65798] When reading Excel files created using SXSSFWorkbook, SheetContentsHandler cell method is getting incorrect formattedValue
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65798
PJ Fanning <fa...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Hardware|Macintosh |All
OS|Mac OS X 10.1 |All
Status|NEW |RESOLVED
--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
This is likely to be a duplicate of
https://bz.apache.org/bugzilla/show_bug.cgi?id=65676 - POI v5.2.0 will be
released in next week or so (hopefully)
*** This bug has been marked as a duplicate of bug 65676 ***
--
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