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));
JRAbstractExporter exporter = new JExcelApiExporter();
// exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE); //EXCEL分頁參數
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outPath);
exporter.setParameter(JRExporterParameter.JASPER_PRINT,print);
exporter.exportReport();
} catch (JRException e) {
e.printStackTrace();
}
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言