Gerar xls usando o jasper

3 respostas
A
Bom dia galera. Eu estou utilizando o metodo abaixo pra gerar relatorios no formato PDF, so que preciso gerar no formato xls(Excel) e não estou conseguindo, alguém poderia me ajudar? Abraços e até a proxima.... ------------------------------------------------------------------------------------
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) {			
		}	 
		
	}

3 Respostas

C

JasperExportManager.exportReportToPdfFile(jp,nome+".pdf");

tem um metodo…

exportReportToXlsFile();…

ja tentou ele ?

A

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");

C

:joia:

Criado 11 de julho de 2006
Ultima resposta 17 de jul. de 2006
Respostas 3
Participantes 2