首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

jasper report 第一个事例

2013-01-26 
jasper report 第一个例子public void jsperReport(){ListpurListnew ArrayList()User usernew User(

jasper report 第一个例子
public void jsperReport(){List purList=new ArrayList();;User user=new User("zhangsan","上海","男",22);purList.add(user);JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(purList);Map<String,Object> pmap = new HashMap<String,Object>();//map.put来存放parameter,以便在页面中通过$p{}获取pmap.put("address", "address");pmap.put("note", "note");InputStream is = null;try {is = this.getClass().getClassLoader().getResourceAsStream("jasper/xxx.jrxml");JasperDesign jasperDesign = JRXmlLoader.load(is);JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, pmap, ds);if (jasperPrint != null&& !jasperPrint.getPages().isEmpty()) {// 打印预览JasperViewer.viewReport(jasperPrint, false);} else {return;}} catch (JRException e) {e.printStackTrace();return;}finally{if(null != is){try {is.close();} catch (IOException e) {}}}}

?

热点排行
Bad Request.