问题解决了。
问题在于我的导出方式,我最初告诉 jasperReports 不要检测细胞类型。
所以解决方法是设置JRXlsExporterParameter.IS_DETECT_CELL_TYPE
为TRUE
.
例如
JRXlsExporter exporterxls2 = new JRXlsExporter();
exporterxls2.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterxls2.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);
exporterxls2.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
exporterxls2.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, reportFile.getPath());
我认为你们中的一些人可能正在使用外部文件来配置导出,在这种情况下,要包含的行是
net.sf.jasperreports.export.xls.detect.cell.type=true
希望能帮助到你 :)