jasper report - display a String value if the decimal field is null

0

In  my report ,  there is a currency field,  eg. $V(A1), it is a Bigdecimal type.

We want to display a "-" if the value is 0 or null. 

The expression is like below:

($V{A1}==null||$V{A1}==0.0)?"-":$V{A1}

It works fine in the PDF format. But when export to xlsx, it will show 

The job was not completed. A system error occurred while running it. java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number at net.sf.jasperreports.engine.JRAbstractExporter.getNumberCellValue(JRAbstractExporter.java:1163) at net.sf.jasperreports.engine.JRAbstractExporter.getTextValue(JRAbstractExporter.java:1104) at net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter.exportText(JRXlsxExporter.java:1199) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:1009) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:804) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:475)

I can know the reason for this. We set the auto detect data type in jasper for xlsx, and the server try to convert "-" to a number.

Is there any solution for this?

 

xuanyuebo's picture
Joined: Sep 29 2011 - 7:57pm
Last seen: 6 years 9 months ago

0 Answers:

No answers yet
Feedback