嘗試了下面的代碼,但未生成PDF報告。剛開始使用Jasper integartion。請幫忙。將Jasper Report與Java集成
public String mainReport() {
HashMap jrxmlParams = null;
try {
System.out.println("Start ....");
// Get jasper report
String jrxmlFileName = "C:/Jasper/DP_crosstabs.jrxml";
JasperReport objJReport = JasperCompileManager.compileReport(jrxmlFileName);
connection = getConnection();
jrxmlParams = new HashMap();
jrxmlParams.put("ID", "null");
JasperPrint objJPrint = JasperFillManager.fillReport(objJReport, jrxmlParams, connection);
ByteArrayOutputStream objBAOutputStream = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(objJPrint, objBAOutputStream);
System.out.println("Done exporting reports to pdf");
} catch (Exception e) {
System.out.print("Exceptiion" + e);
}
return null;
}
添加了所有相關jar文件,可以幫助的人這 – Sainik 2013-02-20 11:09:26
是一個桌面應用程序? – psabbate 2013-02-20 12:21:41