JasperReports: how to format numeric data with Excel exporter

I am using iReport 2.0.2. I am having a problem formatting numeric data after creating a report using Excel exporter.

For example, line 85110057689 displayed as 8.51100e+10 in the Excel file (as a result of using the "Preview in Excel" button in iReport).

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

+6
source share
2 answers

We can use the net.sf.jasperreports.export.xls.detect.cell.type property to solve the problem.

Quote from the documentation:

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

A property whose value is used as the default value for the exported IS_DETECT_CELL_TYPE flag.

Indicates whether the exporter should consider the type of source expressions of the text field and specify the cell types and, respectively.

For example, we can set this property for the entire 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"/> 
+9
source

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

eg. if numeric value = 85110057689, convert the value to string format and format the result as "=" 85110057689 ", where double quotation marks wrap a large number and it is preceded by a" = "sign.

0
source

Source: https://habr.com/ru/post/916424/


All Articles