tbiswas
-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forum
Events
Featured Visualizations
Knowledge Base
Documentation (PDF Downloads)
Blog
Documentation (Test Area)
Documentation
Dr. Jaspersoft Webinar Series
Downloads
Posts posted by tbiswas
-
-
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...
Tanmoy
Code: <%@ 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) { } } }%>
-
No one there to help??
-
Experts....
Is there nothing to say about my problem?
Am I doing any silly mistake?
Need your help.......
Tanmoy
Post Edited by tbiswas at 08/04/2010 05:49 -
Hello,
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 there with this topic in the 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?
Thanks in advance...
Tanmoy
Code: <%@ 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) { } } }%>
Zero file size of exported XLS file
in Products
Posted
Is this forum working?????????????
Anybody there????????????????????