【问题标题】:Number Stored as Text in Excel created using DynamicReports数字存储为 Excel 中使用 DynamicReports 创建的文本
【发布时间】:2016-07-01 22:15:37
【问题描述】:

我正在使用动态报告来创建报告并且能够创建它。但问题是,当我将其转换为 excel 时,excel 中的单元格显示警告为 Number Stored as Text。因此无法进行任何操作。

这是我的代码

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);

如何消除此错误。

【问题讨论】:

  • 你见过this wiki entry吗?
  • @tobi6 但这不是正确的做法。我们不能告诉客户这样做

标签: java jasper-reports dynamic-reports


【解决方案1】:

将以下行添加到您的代码中:

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

Source

编辑

Dynamic Reports samples 中,report 变量还设置了以下内容。这可能会有所帮助,具体取决于列。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-26
    • 1970-01-01
    相关资源
    最近更新 更多