sconilleau Posted April 6, 2011 Share Posted April 6, 2011 Hi, I need to call iReport from an application. I wrote a java class to do so. The code works perfectly for a pdf export but fails for a docx (or rtf) export.I just have this error text :Exception in thread "main" java.lang.ClassCastException: java.lang.Stringat net.sf.jasperreports.engine.export.JRRtfExporter.exportReport(JRRtfExporter.java:207)at geneReportToolkit.ExportToRTF.getRTFReport(ExportToRTF.java:100)at geneReportToolkit.ExportToRTF.main(ExportToRTF.java:41) Here is the export part of the code ThxCode:// Export to rtfString reportName="/tmp/myRtfReport.rtf";JRRtfExporter exporter = new JRRtfExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter(JRExporterParameter.OUTPUT_FILE, reportName);exporter.exportReport(); Link to comment Share on other sites More sharing options...
sconilleau Posted April 8, 2011 Author Share Posted April 8, 2011 Hi everyoneno idea ? Link to comment Share on other sites More sharing options...
NandiniBC Posted April 8, 2011 Share Posted April 8, 2011 Hi,The code "exporter.setParameter(JRExporterParameter.OUTPUT_FILE, reportName);"is setting the file to a parameter. If the file does not exist, it will throw classcast exception, as the code will be something like destFile = (File)parameters.get(JRExporterParameter.OUTPUT_FILE); here the values in the RExporterParameter.OUTPUT_FILE is cast to File.if myRtfReport.rtf does not existexception is thrown hope this helps. Sonata software Limited Link to comment Share on other sites More sharing options...
sconilleau Posted April 8, 2011 Author Share Posted April 8, 2011 Thank you very much. It dit help a lot.I change this line :exporter.setParameter(JRExporterParameter.OUTPUT_FILE, reportName);toexporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, reportName);and now it works. Regards,Sebastien 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