SessionUser user=SessionHelper.getSessionUser();
userid=user.getId();
List<StoreOrder> storeOrders=settlementService.printStoreOrders(userid);
if (storeOrders!=null &&storeOrders.size()>0) {
for (int i = 0; i < storeOrders.size(); i++) {
StoreOrder storeOrder=storeOrders.get(i);
Order order=storeOrder.getOrder();
ordermoney=ordermoney.add(order.getAmount());
paymoney=paymoney.add(storeOrder.getMallMoney());
freight=freight.add(order.getFreight());
}
List<ViewReimbursement> vList=settlementService.loadReimbursements(userid);
if (vList!=null &&vList.size()>0) {
for (int i = 0; i < vList.size(); i++) {
ViewReimbursement v=vList.get(i);
ReimbursementItem reimbursementItem=v.getReimbursement();
realBackMoney=realBackMoney +reimbursementItem.getRealBackMoney();
}
}
settlement=ordermoney.add(freight).subtract(paymoney).subtract(new BigDecimal(realBackMoney));
}
// 设置页面参数
Map paraMap = new HashMap();
// 设置明细list
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(storeOrders);
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("/Settlement.jrxml");
JasperDesign jasperDesign = JRXmlLoader.load(is);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
paraMap.put("ordermoney",ordermoney);
paraMap.put("paymoney",paymoney);
paraMap.put("settlement",settlement);
paraMap.put("realBackMoney", realBackMoney);
paraMap.put("freight", freight);
// 写入报表
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, paraMap, ds);
HttpServletResponse resp = ServletActionContext.getResponse();
JRExporter exporter = new JRPdfExporter();
resp.reset();
resp.setContentType("application/pdf;UTF-8");
resp.setHeader("Content-Disposition", "attachment; filename=\""+ URLEncoder.encode("settlementList", "UTF-8") + ".pdf\"");
OutputStream ouputStream = resp.getOutputStream();
// 使用JRPdfExproter导出器导出pdf
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
exporter.exportReport();
ouputStream.flush();
ouputStream.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
?
详细解决方案
应用 jasperreport 来打印报表
热度:1091 发布时间:2012-12-27 10:17:10.0
相关解决方案
- jasperreport 输出html ,字段里有<> 等都被替换成<>该如何解决
- jasperreport 导出pdf 有关问题
- 在程序里如何给交叉报表(JasperReport)传递参数
- jasperreport flash viewer 棘手有关问题
- jasperreport 经过javabean datasoource实现chart的报表
- JasperReport subdataset datasetRun的有关设置
- 应用 jasperreport 来打印报表
- IReport | Jasperreport 无数据或查询结果集行数替0 依然展现报表
- jasperreport 自学札记
- jasperreport 内容替空的处理
- JasperReport 依据内容动态调整报表行高
- jasperreport 组合struts2开发报表
- JasperReport 种介绍
- jasperreport 导出html px 图片的有关问题
- JasperReport+Servlet Web使用之:导PDF,Excel,Rtf文件
- JasperReport + Servlet Web施用之:HTML显示报表内容
- jasperreport + ireport + struts2 多数据源子报表有关问题
- 请教print.html里面的REPORT_URL是表示的什么路径?(JasperReport)
- 报表有关问题-JasperReport
- jasperReport 的jrxml如何显示 javaBean 中的List
- JasperReport 如何接收应程序传来的集合或对象