bcaramu Posted December 17, 2008 Share Posted December 17, 2008 Hi AllPlease tell me what is problem in my codeI need the solution . Please in this ProblemCode:Exception:Exception in thread "main" java.lang.ClassCastException: net.sf.jasperreports.engine.JasperReport cannot be cast to net.sf.jasperreports.engine.JasperPrint at net.sf.jasperreports.engine.JRAbstractExporter.setInput(JRAbstractExporter.java:640) at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:179) at com.cmc.report.launch.ReportController.main(ReportController.java:108)Source: File sourceFile = (new ClassPathResource(jdbcSampleReportJasperFile)) .getFile(); System.out.println(sourceFile.canRead()); JasperReport jasperPrint = (JasperReport) JRLoader .loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint .getName() + EXTENSION_XLS); JRXlsExporter exporter = new JRXlsExporter(); exporter .setParameter(JRExporterParameter.JASPER_PRINT, report); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE); exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE); exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE); exporter.exportReport(); Link to comment Share on other sites More sharing options...
malani_manish Posted December 18, 2008 Share Posted December 18, 2008 problem is below line in your code.JasperReport jasperPrint = (JasperReport) JRLoader .loadObject(sourceFile); JasperReport is a compiled version of your report and JasperPrint is the filled one. may be the file you are reading is a persisted JasperPrint object. 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