I use JRXlsExporter to write my .xls files it works ok as long as I write in a new file every time, my problem is that i want to append an existing .xls file and add new data to the end of that file.
public static void exportXLS(JasperPrint jasperPrint, String fileName) throws IOException, JRException{ SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration(); configuration.setOnePagePerSheet(true); configuration.setDetectCellType(true); configuration.setCollapseRowSpan(false); configuration.setWhitePageBackground(false); File file = new File(fileName+".xls"); FileOutputStream fos = new FileOutputStream(file,true); JRXlsExporter exporterXLS = new JRXlsExporter(); exporterXLS.setExporterInput(new SimpleExporterInput(jasperPrint)); exporterXLS.setExporterOutput(new SimpleOutputStreamExporterOutput(fos)); exporterXLS.setConfiguration(configuration); exporterXLS.exportReport(); fos.flush(); fos.close() }
1 Answer:
Posted on February 9, 2015 at 5:30pm
Check this Sample, is comes with JR so you should have it under /demo/samples/xlsfeatures/
http://jasperreports.sourceforge.net/sample.reference/xlsfeatures/#xlsfe...
You need to use the net.sf.jasperreports.export.xls.workbook.template property See the section "Embedding Content From External Documents Into The Generated Document "