Dynamicjasper Excel和领先的撇号
我使用DynamicJasper
来生成一个Excel工作表。 我遇到一些撇号前加到我的date列值的一些困难。
我这样定义我的专栏:
AbstractColumn dateColumn = ColumnBuilder.getNew().setColumnProperty( title.getUniqueId(), Date.class.getName()).setTitle(title.getTitle()). setWidth(150).setFixedWidth(false).setPattern("dd MMM yyyy").build(); drb.addColumn(dateColumn);
然后添加适当的date值到我的地图…..
一切都很好,除了excel列中的每个date都是带有前导撇号的string,并且该列不包含date。
撇号如何到达那里? 为什么列没有格式化为date?
我将不胜感激任何指针。
问题解决了。
问题出在我出口的方式,我原来告诉jasperReports不要检测单元格types。
所以修正是将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());
我认为你们中有些人可能使用外部文件来configuration导出,在这种情况下,要包含的行是net.sf.jasperreports.export.xls.detect.cell.type=true
希望能帮助到你 :)