嗨,我对碧玉报告很陌生。只是有一个要求,我需要从 .jasper 文件中检索信息。我正在使用下面的代码。
但问题是 compileReport 不占用我在本地机器上的文件,我收到类似的错误
线程“main”中的异常 java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:150) at jasper.test(jasper.java:28 ) 在 jasper.main(jasper.java:40)
我不确定出了什么问题。它无法获取我的 .jasper 文件吗?哪一门课不见了?我完全一无所知。
我的代码是:
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import dori.jasper.engine.JRException;
import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.view.JasperViewer;
public class jasper {
public static void test() throws FileNotFoundException, net.sf.jasperreports.engine.JRException{
JasperReport report = JasperCompileManager.compileReport("C:\\Users\\Mandakini\\Downloads\\testReport.jasper");
JasperPrint print = JasperFillManager.fillReport(report, new HashMap<String, String>());
// export it!
//File pdf = File.createTempFile("output.", ".pdf");
OutputStream output= new FileOutputStream(new File("F:/catalog.pdf"));
JasperExportManager.exportReportToPdfStream(print,output);
}
public static void main(String args[]) throws FileNotFoundException, net.sf.jasperreports.engine.JRException{
test();
}
}
谢谢