JasperReports: How to format numeric data with Excel exporter

心不动则不痛 提交于 2019-11-29 07:17:52
Naim Nsco

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"/>

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!