java - Jasper report error when exporting report to docx -
i'm trying export jasper report .docx file; i'm getting error
java.lang.classcastexception: java.lang.string cannot cast net.sf.jasperreports.engine.jasperprint
i'm using java develop this.
here code used
public void generatereport2() throws printerexception { try { string sourcefilename = "src/pos_bill/esfourreport.jasper"; string printfilename = null; databeanfactory2 databean = new databeanfactory2(); jrbeancollectiondatasource beancoldatasource = new jrbeancollectiondatasource(databean.generatecollection()); map parameters = new hashmap(); printfilename = jasperfillmanager.fillreporttofile( sourcefilename, parameters, beancoldatasource); jrdocxexporter exp=new jrdocxexporter(); exp.setparameter(jrexporterparameter.jasper_print,printfilename); exp.setparameter(jrexporterparameter.output_file_name,"src/pos_bill/sample_report2.docx"); exp.exportreport(); } catch (exception e) { system.out.println(e); } }
finally found answer!
i removed these 2 lines
exp.setparameter(jrexporterparameter.jasper_print,printfilename); exp.setparameter(jrexporterparameter.output_file_name,"src/pos_bill/sample_report2.docx");
and replaced these
exporter.setexporterinput(new simpleexporterinput(printfilename)); exporter.setexporteroutput(new simpleoutputstreamexporteroutput("src/pos_bill/samplereport2.docx"));
and works finely!
Comments
Post a Comment