在使用DynamicReports创建的Excel中存储为文本的数字

时间:2016-07-01 09:39:16

标签: java jasper-reports dynamic-reports

我正在使用动态报告创建报告,并且能够创建报告。但问题是当我将其转换为excel时,excel中的单元格显示警告为存储为文本的数字。因此,无法进行任何操作。

这是我的代码

File file = new File("c:/report.xls");

JasperXlsExporterBuilder xlsExporter = export.xlsExporter(file).setDetectCellType(true).setIgnorePageMargins(true)
                .setWhitePageBackground(false).setRemoveEmptySpaceBetweenColumns(true);

report.addProperty(JasperProperty.EXPORT_XLS_FREEZE_ROW, "2").ignorePageWidth().ignorePagination().toXls(xlsExporter);

如何删除此错误。

1 个答案:

答案 0 :(得分:0)

在代码中添加以下行:

<property name="net.sf.jasperreports.export.xls.detect.cell.type" value="true"/>

Source

修改

Dynamic Reports samples中,报表变量还会设置以下内容。这可能有助于取决于专栏。

.columns(
    itemColumn,
    col.column("Quantity",   "quantity",  type.integerType()),
    col.column("Unit price", "unitprice", type.bigDecimalType()))