JasperPrint jasperPrint;
JRResultSetDataSource jrds=null;
String filePath = application.getRealPath("test.jasper");
/* 設定輸出 PDF 檔的路徑位置 */
String outPath = application.getRealPath("\\pdf\\test_"+Pdf_Name+".pdf");
try {
/* 帶參數進去給報表 */
Map map = new HashMap();
map.put("name","王小明");
JasperPrint print = JasperFillManager.fillReport(filePath,map, new JRResultSetDataSource(rs));
JRExporter exporter =new net.sf.jasperreports.engine.export.JRPdfExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outPath);
exporter.setParameter(JRExporterParameter.JASPER_PRINT,print);
exporter.exportReport();
}
catch (JRException e)
{
e.printStackTrace();
System.exit(1);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(1);
}
沒有留言:
張貼留言