ireport 动态修改标题以及表头,本人亲试,绝对靠谱!!!

来源:互联网 发布:生意参谋淘宝版下载 编辑:程序博客网 时间:2024/06/01 03:57
@RequestMapping("seatCheckInAndCheckOutQuery")
public String seatCheckInAndCheckOutQuery(Model model, SignIn sign, String format) throws Exception{
Map parameters = new HashMap();  
        parameters.put("beginDate","查询时间范围:"+sign.getSignInId()); 
       
List<JasperInfoTen> list = signService.findSeatCheckInAndOutCondtion(sign);
JRDataSource jrDataSource = new JRBeanCollectionDataSource(list);

model.addAllAttributes(parameters);
model.addAttribute(Constant.URL, "/WEB-INF/jasper/actionDataJasper/seatCheckInAndCheckOut.jasper");
model.addAttribute("sign", sign);
model.addAttribute(Constant.FORMAT, format); 
model.addAttribute(Constant.JRMAINDATASOURCE, jrDataSource);
model.addAttribute(Constant.FILENAME,DateTime.currentDate()+"sign");

return Constant.STATISJASPER;

}

我们只需要在ireport工具里面定义一个parameters,名字与map集合的键保持一致就可以取到我们传入的参数,该方法自动生成html和excel。

本人用的ireport5.6

原创粉丝点击