Jump to content
Changes to the Jaspersoft community edition download ×

Export failure


sconilleau

Recommended Posts

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.String

at 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

 

Thx

Code:
// 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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

 

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 exist

exception is thrown

 

hope this helps.

 

Sonata software Limited

 

Link to comment
Share on other sites

Thank you very much. It dit help a lot.

I change this line :

exporter.setParameter(JRExporterParameter.OUTPUT_FILE, reportName);

to

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, reportName);

and now it works.

 

Regards,

Sebastien

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...