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 2013/10/16 12:51:48 UTC
[Bug 55658] New: SXSSFCell.convertCellValueToString() incorrectly
implemented for CELL_TYPE_NUMERIC
https://issues.apache.org/bugzilla/show_bug.cgi?id=55658
Bug ID: 55658
Summary: SXSSFCell.convertCellValueToString() incorrectly
implemented for CELL_TYPE_NUMERIC
Product: POI
Version: 3.9
Hardware: All
OS: All
Status: NEW
Severity: blocker
Priority: P2
Component: SXSSF
Assignee: dev@poi.apache.org
Reporter: piers.geyman@indigoinspirations.co.uk
When you call cell.setValue( myValue ) for a numeric cell when using SXSSF the
call fails with the following error:
java.lang.IllegalStateException: Cannot get a error value from a numeric cell
at org.apache.poi.xssf.streaming.SXSSFCell.typeMismatch(SXSSFCell.java:841)
at
org.apache.poi.xssf.streaming.SXSSFCell.getErrorCellValue(SXSSFCell.java:487)
at
org.apache.poi.xssf.streaming.SXSSFCell.convertCellValueToString(SXSSFCell.java:891)
at org.apache.poi.xssf.streaming.SXSSFCell.setType(SXSSFCell.java:760)
at
org.apache.poi.xssf.streaming.SXSSFCell.ensureTypeOrFormulaType(SXSSFCell.java:744)
at org.apache.poi.xssf.streaming.SXSSFCell.setCellValue(SXSSFCell.java:235)
Looking at the code in
org.apache.poi.xssf.streaming.SXSSFCell.convertCellValueToString it has an
incorrect case for CELL_TYPE_NUMERIC. There is no implementation and it just
uses the same code as CELL_TYPE_ERROR, which is obviously incorrect:
private String convertCellValueToString() {
int cellType = getCellType();
switch (cellType) {
case CELL_TYPE_BLANK:
return "";
case CELL_TYPE_BOOLEAN:
return getBooleanCellValue() ? "TRUE" : "FALSE";
case CELL_TYPE_STRING:
return getStringCellValue();
case CELL_TYPE_NUMERIC:
case CELL_TYPE_ERROR:
byte errVal = getErrorCellValue();
return FormulaError.forInt(errVal).getString();
case CELL_TYPE_FORMULA:
return "";
default:
throw new IllegalStateException("Unexpected cell type (" +
cellType + ")");
}
}
What should this code be? Is there an existing patch I can apply? This bug
makes using SXSSF un-useable. I have a project that I have big memory issues
with when using XSSF and need this implementation.
If this is just a case of converting the NumericCell value to a string, then
why not just do:
case CELL_TYPE_NUMERIC:
return Double.toString( getNumericCellValue() );
Or to be more OO, why not override toString() on the class NumericValue?
--
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 55658] SXSSFCell.convertCellValueToString() incorrectly
implemented for CELL_TYPE_NUMERIC
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55658
Dominik Stadler <do...@gmx.at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #1 from Dominik Stadler <do...@gmx.at> ---
I took a look, it only happens if you set a cell first to a numeric value and
then set a string value to the same cell.
So a workaround for now might be to only set the value of the cell once during
creation of the xlsx.
I fixed it for the next release, see r1532873 in SVN.
--
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