tbiswas Posted August 10, 2010 Share Posted August 10, 2010 Hello,I have posted this topic in jasper server's forum, but no replies.I am new to JasperServer and iReport tools. I have created one .jasper file using iReport for testing. In my tomcat I have used all the required JAR files for JasperServer. I have created one JSP file and want to create report based on that .jasper file into different file format like PDF, CSV, RTF, XLS etc. My JSP code is in Code section: - Problem with this code is, all the other file format is working properly except the xls format. It produsing an empty file with no data.Can anybody please help me on this issue?Am I doing any silly mistake?I need help on this.Thanks in advance...TanmoyCode:<%@ page language="java" import="net.sf.jasperreports.engine.*,net.sf.jasperreports.engine.export.*" %><%@ page import="java.sql.*,java.io.*" %><% String filename = "D:/Program Files/jasperserver-ce-3.7.0/ireport/ireport/reports/test.jasper"; String reporttype = "xls"; Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/myDB", "root", "root"); System.out.println("Connection Established"); JasperPrint jasperPrint = JasperFillManager.fillReport(filename, null, conn); System.out.println("Report Created..."); OutputStream ouputStream = response.getOutputStream(); JRExporter exporter = null; if ("pdf".equalsIgnoreCase(reporttype)) { response.setContentType("application/pdf"); exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } else if ("rtf".equalsIgnoreCase(reporttype)) { response.setContentType("application/rtf"); response.setHeader("Content-Disposition", "inline; filename=\"file.rtf\""); exporter = new JRRtfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } else if ("html".equalsIgnoreCase(reporttype)) { exporter = new JRHtmlExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } else if ("xls".equalsIgnoreCase(reporttype)) { response.setContentType("application/xls"); response.setHeader("Content-Disposition", "inline; filename=\"file.xls\""); exporter = new JRXlsExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } else if ("csv".equalsIgnoreCase(reporttype)) { response.setContentType("application/csv"); response.setHeader("Content-Disposition", "inline; filename=\"file.csv\""); exporter = new JRCsvExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream); } try { exporter.exportReport(); } catch (Exception e) { System.out.println(e); } finally { if (ouputStream != null) { try { ouputStream.close(); } catch (IOException ex) { } } }%> Link to comment Share on other sites More sharing options...
tbiswas Posted August 12, 2010 Author Share Posted August 12, 2010 Is this forum working?????????????Anybody there???????????????????? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now