JasperReports: How to format numeric data with Excel exporter

2012-05-23 jasper-reports export-to-excel number-formatting ireport

I'm using iReport 2.0.2. I have a problem with formatting numeric data after generating report with help of Excel exporter.

For example, the 85110057689 string is showing as 8.51100e+10 in Excel file (as result of using "preview in Excel" button in iReport).

Please suggest how to change the format to the simple (not scientific).


To prevent large number displayed in scientific notation in Excel, make sure instead of value, you are putting ="value" in excel cell.

e.g. if numeric value = 85110057689, convert value in string format and format the result as '="85110057689"' where doublequotes wrap the big number and there is a '=' sign in front.

We can use net.sf.jasperreports.export.xls.detect.cell.type property for solving issue.

The quote from documentation:


Property whose value is used as default state of the IS_DETECT_CELL_TYPE export flag.

Specifies whether the exporter should take into consideration the type of the original text field expressions and set the cell types and values accordingly.

For example we can set this property for the whole report:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" ...>
    <property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>