https://issues.apache.org/bugzilla/show_bug.cgi?id=55384
Bug ID: 55384
Summary: Setting a precalculated String value on a formula cell
clears out the cell
Product: POI
Version: 3.9
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: SXSSF
Assignee: [email protected]
Reporter: [email protected]
Created attachment 30713
--> https://issues.apache.org/bugzilla/attachment.cgi?id=30713&action=edit
The generated spreadsheet showing the missing information in cell B11
Trying to set a precalculated String value on a formula cell fails totally,
leaving absolutely no information in that cell in the generated spreadsheet.
This is counter to what is written in the API for SXSSFCell (and for that
matter, the Cell interface as well), which states: "Note, this method only sets
the formula string and does not calculate the formula value. To set the
precalculated value use setCellValue(double) or setCellValue(String)"
Here is a snippet of code that demonstrates this incorrect behavior. This code
will generate a spreadsheet with 11 rows, the last one (row #11) being sums of
their respective columns. In column A (cell A11), no precalculated value is
set. In column B (cell B11), a precalculated value is set as a String and here
is where we see the failure, with absolutely no information existing in the
generated spreadsheet. In column C (cell C11), a precalculated value is set as
an integer, and that performs as expected.
I've also attached a copy of the generated spreadsheet to this report.
SXSSFWorkbook wb = new SXSSFWorkbook(100);
Sheet sh = wb.createSheet();
for(int rownum = 0; rownum < 10; rownum++){
org.apache.poi.ss.usermodel.Row row = sh.createRow(rownum);
for(int cellnum = 0; cellnum < 3; cellnum++){
Cell cell = row.createCell(cellnum);
cell.setCellValue(rownum + cellnum);
}
}
org.apache.poi.ss.usermodel.Row row = sh.createRow(10);
// setting no precalculated value works just fine.
Cell cell1 = row.createCell(0);
cell1.setCellFormula("SUM(A1:A10)");
// but setting a precalculated STRING value fails totally
Cell cell2 = row.createCell(1);
cell2.setCellFormula("SUM(B1:B10)");
cell2.setCellValue("55");
// setting a precalculated int value works as expected
Cell cell3 = row.createCell(2);
cell3.setCellFormula("SUM(C1:C10)");
cell3.setCellValue(65);
FileOutputStream out = new FileOutputStream("/temp/sxssf.xlsx");
wb.write(out);
out.close();
Please also note that I have not had a chance to test this outside of the SXSSF
component, so I'm unsure as to whether or not this bug is isolated to SXSSF or
exists in the general case.
Thanks!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]