Olá,
estou tentando gerar um xls a partir de jasper mas gera o xls zerado …
O que está errado alguém pode me ajudar …
abs
response.setContentType("application/excel");
response.setHeader("Content-Disposition","attachment; filename=c:\\output\\exemplo.xls");
String locationImage = request.getContextPath()+ "/imagem/mirax.jpg";
System.out.println("locationImage (host+image)="+host+locationImage);
//trata imagem MANAGER
Session session = (Session) manager.getDelegate();
con = session.connection();
System.out.println("Wait while loadding Report...2");
Map parameters = new HashMap();
System.out.println("Tipo de Grupo = "+request.getParameter("tipo_grupo"));
parameters.put("tipo_grupo", Long.valueOf(request.getParameter("tipo_grupo")));
parameters.put("imagem_dir", host+locationImage);
String jasper = request.getContextPath()+ "/reports/Grupo001.jasper";
@SuppressWarnings("unused")
URL jasperURL = new URL(host + jasper);
System.out.println("Getting the binary..."+jasperURL);
JasperReport relatoriosJasper = (JasperReport)JRLoader.loadObject(jasperURL);
JasperPrint jasperPrint = JasperFillManager.fillReport(relatoriosJasper, parameters, con);
ByteArrayOutputStream output = new ByteArrayOutputStream();
OutputStream outputfile= new FileOutputStream(new File("c:/output/"+relatoriosJasper.getName()+".xls"));
// coding For Excel:
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output);
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.exportReport();
outputfile.write(output.toByteArray());