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?
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.