Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm trying to develop excel page using jasper report

I am working on Jasper report. I try to generate excel file but I am getting exception my code below.

JasperReport jasperReport = JasperCompileManager.compileReport("C:\\jasper files\\report1.jrxml"); 
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), new JREmptyDataSource());

JRXlsExporter exporterXLS = new JRXlsExporter(); 
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint); 
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, "sample1.xls"); 
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); 
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE); 
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); 
exporterXLS.exportReport(); 

Exception isCaused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Sheet at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more

like image 608
Naresh Avatar asked Dec 12 '12 09:12

Naresh


People also ask

How do I create a report from Jasper in Excel?

JasperReport report = JasperCompileManager. compileReport(design); Now, obtain a JDBC connection to retrieve data from the database, in order to create your PDF/Excel report: InitialContext initialContext = new InitialContext(); DataSource ds = (DataSource)initialContext.

Is Jasper a reporting tool?

JasperReports is an open source Java reporting tool that can write to a variety of targets, such as: screen, a printer, into PDF, HTML, Microsoft Excel, RTF, ODT, comma-separated values (CSV) or XML files. It can be used in Java-enabled applications, including Java EE or web applications, to generate dynamic content.

What is Jasper report developer?

Jaspersoft Studio is a powerful desktop report designer for developing data visualizations and full-fledged reports. Featuring the industry's most advanced design environment, it enables you to create highly formatted, pixel-perfect reports and data visualizations.


1 Answers

You need to include the Apache POI jar in your CLASSPATH, Apache POI jar is needed for excel export, the message you are getting is it cannot find the POI class.

You can obtain POI jar from http://poi.apache.org/

Also see here for a similar answer to your question.

like image 185
Nelson Avatar answered Sep 30 '22 04:09

Nelson