jasper没有格式化excel数据类型 [英] jasper not formatting excel data types

查看:114
本文介绍了jasper没有格式化excel数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jasper报告,除了Excel之外,所有格式的导出似乎都很好。

I have a Jasper Report which seems to be exporting fine in all formats except Excel.

下面的示例是一列,应格式化为货币但显示不正确。

The below sample is of a column that should be formatted as currency but shows incorrectly.

以下是我正在使用的jasper属性...

Here are the jasper properties i'm using...

out = new FileOutputStream(file);
JExcelApiExporter exporterXLS = new JExcelApiExporter();

exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.CREATE_CUSTOM_PALETTE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, out);

exporterXLS.exportReport();

我已经尝试了Jasper 4.0和4.5。我认为这与依赖有关,但我不确定。

I've tried both Jasper 4.0 and 4.5. I think it has to do with a dependency but i'm not sure.

推荐答案

已修复!

而不是使用 JRXlsExporterParameter 类我使用如下参数并且它有效!

Instead of using the JRXlsExporterParameter class i used the parameters as follows and it worked!

    jasperPrint.setProperty("net.sf.jasperreports.export.xls.create.custom.palette", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.one.page.per.sheet", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.remove.empty.space.between.rows", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.remove.empty.space.between.columns", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.white.page.background", "true");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.detect.cell.type", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.size.fix.enabled", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.ignore.graphics", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.collapse.row.span", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.ignore.cell.border", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.ignore.cell.background", "false");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.max.rows.per.sheet", "0");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.wrap.text", "true");
    jasperPrint.setProperty("net.sf.jasperreports.export.xls.use.timezone", "false");

这篇关于jasper没有格式化excel数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆