成千上万的格式导出Excel – DynamicReports

我正在使用DynamicReports 4.0,我有一个问题导出Excel中的数字和十进制值。 值以文本格式显示,我需要以“#,###。##”格式显示数值格式和小数。

我需要在标题中的值,这是行不通的:

HorizontalListBuilder hlb = cmp.horizontalList(); hlb.newRow().add( cmp.text(1000).setPattern("#,###.##") ); ComponentBuilder<?, ?> componentBuilder = hlb; 

我希望有人能帮助我。

非常感谢

 hlb.newRow().add( cmp.text("1000").setPattern("#,###.##") ); 

最后,我find了解决我的问题的答案。 我只需要为我的报告添加下一个属性:

 JasperReportBuilder builder = report() .addProperty("net.sf.jasperreports.export.xls.detect.cell.type", "true") 

我在下一个链接中find了这个和其他有用的属性:

http://jasperreports.sourceforge.net/config.reference.html

也许这是可以帮助你的:

 DecimalFormat df = new DecimalFormat("#,###.##"); hlb.newRow().add( cmp.text(df.format(Float.parseFloat(1000))) );