Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JasperReports: How to format numeric data with Excel exporter

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

like image 244
Naim Nsco Avatar asked May 23 '12 06:05

Naim Nsco


People also ask

How do I change the number format in Jasper report?

The best way to format in jasper report is to use the pattern attribute on the textField tag. This will keep correct class (Number), when exporting to for example excel, excel can identify it as number and will also apply same pattern.

What is pattern expression in Jasper?

In the Pattern Expression you should not be returning a pattern, but rather a string from which a pattern will be made. For example, in my report I wanted numbers formatted as "#,##0.00;(#,##0.00)" but when the field label was "Net Invoiced" i wanted the output to be bold. So, in Pattern Exp.

How do I export a Jasper report?

To view and save the report in other formats, click the Export button. 2. Select an export format from the drop-down. The export options are listed in the figure Export File Types.


1 Answers

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

The quote from documentation:

net.sf.jasperreports.export.xls.detect.cell.type

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"/>
like image 81
Naim Nsco Avatar answered Sep 21 '22 23:09

Naim Nsco