Search code examples
javajasper-reportsdynamic-reports

Number Stored as Text in Excel created using DynamicReports


I am using Dynamic Reports to create Reports and am able to create it. But the issue is that when i convert it to excel, the cell in the excel showing a warning as Number Stored as Text. Because of this no operation is possible.

Here is my code

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

How to remove this error.


Solution

  • Add the following line to your code:

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

    Source

    EDIT

    In the Dynamic Reports samples, the report variable also sets the following. This could help depending on the column.

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