List sourceList = dao.rundata();
if(sourceList.size() < sourcelist =" java.util.Collections.EMPTY
}
2.實作一個Map物作來存放變數
Map
par.put("par1", "par1-test1");
par.put("par2", "test2");
3.取出jasper檔案
File jasperFile= new File( config.getServletContext()
4.將.jasper File轉成jasperReport
JasperReport jr = (JasperReport) net.sf.jasperreports.engine
5.將sourceList 轉成 JRDataSource
net.sf.jasperreports.engine
jrds = new net.sf.jasperreports.engine
6.從指定的jasperReport 檔案compiled成report design loaded
net.sf.jasperreports.engine
7.Exports the generated report object received as parameter into PDF format and returns the binary content as a byte array.
byte[] bytes = net.sf.jasperreports.engine
8.將byte array透過response輸出成PDF
.
.(略)
response.setHeader("Content
response.reset();
if (bytes != null && bytes.length != 0) {
response.setContentLength
ServletOutputStream os = response.getOutputStream();
os.write(bytes, 0, bytes.length);
} else {
throw new IllegalStateException("fail to create pdf file");
}
response.flushBuffer();
.(略)
.
沒有留言:
張貼留言