我正在尝试使用jasper报告开发excel页面

Nar*_*esh 6 java excel jasper-reports

我正在研究Jasper报告.我尝试生成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(); 
Run Code Online (Sandbox Code Playgroud)

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

Nel*_*son 4

您需要将 Apache POI jar 包含在 CLASSPATH 中,Excel 导出需要 Apache POI jar,您收到的消息是找不到 POI 类。

您可以从http://poi.apache.org/获取 POI jar

另请参阅此处以获取与您的问题类似的答案。