martynhiemstra Posted July 27, 2007 Share Posted July 27, 2007 Hi All, I am using the JRRtfExporter exporter to export a report to a rtf document. At least something that is readable in Word. I can export my report to pdf and excel but wen I use the JRRtfExporter I see this on the screen. {rtf1ansideff0{fonttbl {f0fnil sansserif;}{f1fnil Arial;}}{colortbl ;red0green0blue0;red255green255blue255;}{info{nofpages7}}etc etc....a long file I am using the following code: JRRtfExporter exporterRTF = new JRRtfExporter ( );exporterRTF.setParameter ( JRXlsExporterParameter.JASPER_PRINT, jasperPrint );exporterRTF.setParameter ( JRXlsExporterParameter.OUTPUT_STREAM, response.getOutputStream ( ) );exporterRTF.exportReport ( ); When I use the pdf and excel exporter the browser askes me the question if I want to save or open the file but the JRRtfExporter just streams the contents to the screen. I want the browser to stream the file and not display the contents on the screen so our clients can download the rtf file. Thanks in advance,Martyn Link to comment Share on other sites More sharing options...
lucianc Posted July 27, 2007 Share Posted July 27, 2007 You need to set the appropriate headers so that the browser recognizes the response type. Try something likeCode:response.setContentType("application/rtf"«»);response.setHeader("Content-Disposition", "inline; filename="file.rtf""«»); HTH,Lucian Link to comment Share on other sites More sharing options...
kdegraaf Posted March 3, 2008 Share Posted March 3, 2008 Hi martynhiemstra, Could you pleas paste your code here on how you make a RTF an XLS that could be downloaded by the client? I'm Trying to make this for a few days now, but still don't know how to code it. Thanks in advance. Link to comment Share on other sites More sharing options...
kdegraaf Posted March 4, 2008 Share Posted March 4, 2008 Got it! Code: JRRtfExporter exporter = new JRRtfExporter(); HttpServletResponse response = JSFUtils.getServletResponse(); response.setHeader("Content-disposition", "attachment; filename="+raportName+".rtf"«»); response.setContentType("application/x-download"«»); OutputStream outputStream = response.getOutputStream(); HashMap hm = new HashMap(); InputStream reportStream = JSFUtils.getExternalContext().getResourceAsStream(raportTemplate); JasperPrint jasperPrint = //JasperManager.fillReport(reportStream, hm, appModule.getCurrentConnection()); JasperFillManager.fillReport(reportStream, hm, appModule.getCurrentConnection()); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream); exporter.exportReport(); outputStream.flush(); outputStream.close(); JSFUtils.getFacesContext().responseComplete(); For XLS use: JRXlsExporter exporterXLS = new JRXlsExporter(); 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