古詩詞大全網 - 成語查詢 - jasper怎麽設置主報表循環打印完再打印子報表

jasper怎麽設置主報表循環打印完再打印子報表

百度知道

怎樣實現JasperReport循環打印 or 多表打印

10我用的是FineReport,比較方便,jasperreport不太了解。下面是百度的答案,希望對妳有幫助。批量導出思路如下:1、數據庫裏面取出數據2、調用項目工具類中生成報表打印數據的方法(每張表數據都要放到壹個list集合中)java 代碼String path = this.getClass().getResource("/").getPath();path = path.substring(1,path.lastIndexOf("classes"));String fileName = path+"jasperreport"+"\"+reportFileName+".jasper";System.out.println("_________ FileName:"+fileName);//裝載jasper文件applicationFile reportFile = new File(fileName);Map map = new HashMap();JasperReport jasperReport = null;DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");String s = format1.format(new Date());//取得JasperPrint 的集合for (Object e : list) {List<Evaluate> tempList = new ArrayList<Evaluate>();tempList.add((Evaluate)e);jasperPrint = JasperFillManager.fillReport(reportFile.getPath(),null,new JRBeanCollectionDataSource(tempList));list2.add(jasperPrint);}//生成報表數據並填入OutputStreamJRPdfExporter exporter=new JRPdfExporter ();ServletOutputStream output = null;try {output = getResponse().getOutputStream();getResponse().setHeader("Content-disposition","attachment; filename="+exportFileName+s+".pdf");//exportFileName導出文件名字 s 表示年月日時分秒exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, list2);exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,output);// exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, list);exporter.setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8");exporter.exportReport();} catch (Exception e) {e.printStackTrace();}