public void GerarPDF(String nome){
JasperPrint jp;
try {
jp = JasperFillManager.fillReport("modelos-JASPER/"+nome+".jasper",
parameters,obj.con );
JasperExportManager.exportReportToPdfFile(jp,nome+".pdf");
Runtime.getRuntime().exec("rundll32.exe Shell32.dll,
ShellExec_RunDLL "+nome+".pdf");
}
catch (IOException e) {
}
catch (JRException e) {
}
}
Gerar xls usando o jasper
3 Respostas
JasperExportManager.exportReportToPdfFile(jp,nome+".pdf");
tem um metodo…
exportReportToXlsFile();…
ja tentou ele ?
jasperReport = (JasperReport)JRLoader.loadObject(reportFile.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,obj.con);
JRXlsExporter exporter = new JRXlsExporter();
File destFile = new File(nome+".xls");
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,destFile.toString());
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
exporter.exportReport();
Runtime.getRuntime().exec("rundll32.exe Shell32.dll,ShellExec_RunDLL "+nome+".xls");
:joia: