I have recently upgraded the Jasper Reports library for my project, from 3.7.6 to 6.0.0. I can finally Maven build and the reports are working just great. However, the setParameter() function appears to have been deprecated between releases, and I am unsure how to refactor my code to accommodate for this.
Example of Deprecated Code:
private static void exportMultipleToCSV(Collection<JasperPrint> jasperPrints, OutputStream baos) throws JRException {
JRCsvExporter csvExporter = new JRCsvExporter();
csvExporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
csvExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
csvExporter.setParameter(JRTextExporterParameter.PAGE_HEIGHT, Integer.valueOf(1500000));
csvExporter.setParameter(JRTextExporterParameter.PAGE_WIDTH, Integer.valueOf(40000000));
csvExporter.setParameter(JRTextExporterParameter.CHARACTER_WIDTH, Integer.valueOf(4));
csvExporter.setParameter(JRTextExporterParameter.CHARACTER_HEIGHT, Integer.valueOf(15));
csvExporter.exportReport();
}
I have looked through the SourceForge page, and can see that it has been replaced by ExporterInput, ExporterConfiguration and ExporterOutput but I am unsure how to utilise them all together to achieve the desired output.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…