2012-12-12 23 views
6

我工作的碧玉報告的Excel頁面。我嘗試生成excel文件,但我得到以下異常我的代碼。我試圖開發使用碧玉報告

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(); 

例外是Caused 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

回答

4

您需要在您的CLASSPATH中的Apache POI罐子,需要的Apache POI罐子Excel導出,你所得到的消息是找不到POI類。

您可以獲取POI罐子從http://poi.apache.org/

也看到here一個類似的回答你的問題。

+0

謝謝尼爾森。我會試試.. – Naresh

+0

我出去了。非常感謝你.. – Naresh