Spring + jasperreport (4) Subreport

북마크 추가

WORD, EXCEL형식 SubReport사용

 

ReportController.java

 

@Controller

  public class ReportController {

  @RequestMapping(value = "/reports/test.do")

  public ModelAndView test(

  @ModelAttribute(“testVO") TestVO testVO,

  Map<String, Object> map, ModelMap model) throws Exception{

---본인 프로젝트에 맞는 방법으로 쿼리를 실행하여 값을 리스트에 담는다---

          List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();

          List<Map<String,Object>> list2 = new ArrayList<Map<String,Object>>();      à SubReportData List

         ~생략~

         

          JRBeanCollectionDataSource src = new JRBeanCollectionDataSource(list);

          JRBeanCollectionDataSource src2 = new JRBeanCollectionDataSource(list2);    à SubReportDatasource

         

          Map parameters = new HashMap();

          parameters.put("dataSource", src);

          parameters.put("subdata", subSrc);         à iReport에서 설정한 이름을 키값으로 Datasource를 넣는다.

          JasperPrint jasperPrint = JasperFillManager.fillReport(reportPath, parameters ,src);

 

         ~생략~ 

HKH
2014-07-13 18:52
SHARE
keyboard_arrow_left
keyboard_arrow_up