Skip to content
Advertisement

Receiving Cannot get a NUMERIC value from a BOOLEAN cell when exporting XML map

I have a workbook with an XML mapping defined (I am using POI 4.1.2).

A mapped cell contains a formula which evaluates to boolean: =AND(B70="";B71=""; B50="No")

I try to export the XML mapping with the following code:

JavaScript

The last line results to the following exception:

java.lang.IllegalStateException: Cannot get a NUMERIC value from a BOOLEAN cell at org.apache.poi.xssf.usermodel.XSSFCell.typeMismatch(XSSFCell.java:1035) at org.apache.poi.xssf.usermodel.XSSFCell.getNumericCellValue(XSSFCell.java:319) at org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(DateUtil.java:765) at org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(DateUtil.java:744) at org.apache.poi.xssf.extractor.XSSFExportToXml.mapCellOnNode(XSSFExportToXml.java:281)

When i look into XSSFExportToXml.mapCellOnNode(XSSFCell, Node) I see the following code:

JavaScript

From my understanding there is a bug in mapCellOnNode. Inside case FORMULA the expression cell.getCachedFormulaResultType() returns BOOLEAN but inside this block only STRING and NUMERIC are considered. This leads to executing DateUtil.isCellDateFormatted(cell) which results in an Exception.

So my question is: am I right? Is it a bug? Or am I missing something?

Advertisement

Answer

I have applied a fix to the POI code – see https://bz.apache.org/bugzilla/show_bug.cgi?id=65492 – this will be included in next POI release

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement