Im using DynamicJasper
to generate an Excel sheet. Im experiencing some difficulty with the apostrophe prepended to my date columns values.
I defined my column like this:
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);
Then added the appropiate Date values to my map.....
Everything is fine, apart from the fact that each date in the excel column is a string with a leading apostrophe, and the column is not formated as containing dates.
How is the apostrophe getting there? And why is the column not formatting as a Date?
I would appreciate any pointers.
Problem solved.
The issue was with the way i was exporting, i had origionaly told jasperReports to not detect cell type.
So the fix was to set JRXlsExporterParameter.IS_DETECT_CELL_TYPE
to TRUE
.
EG
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());
I think some of you may be using an external file to configure the export, in that case the line to include is
net.sf.jasperreports.export.xls.detect.cell.type=true
Hope it helps :)