2010-03-23 6 views
2

jasper report를 사용하여 JRDataSource를 사용하여 pdf 문서를 만들고 싶습니다. 사실 객체에 하나의 bean 객체가 있습니다. 다른 bean 객체와 string 값 목록, 내부 bean 객체에는 두 개의 String 변수가 있습니다. jrxml 문서에서이 세 변수를 모두 매핑하여 pdf 문서의 값을 채 웁니다. 아무도 나를이 문제를 해결하는 방법을 도울 수 있습니다. 만약 당신이 나에게 몇 가지 코드를 제공 할 수 있습니다.이 JRDataSource를 채우는 방법?

답변

0

컬렉션 데이터 소스에서 JasperPrint 객체를 만드는 코드 스 니펫.

JasperPrint jp = new JasperPrint(); 
String reportPath = "/HD/jasper/mypath/myfile.jasper"; 

Map paramsMap = new HashMap(); //put whatever parameters you want to pass to report 

//JR data source, populate with your collection 
JRDataSource reportSource = new JRBeanCollectionDataSource(reportCollection); 

jp = JasperFillManager.fillReport(reportPath, paramsMap, reportSource); 

//Here you can use the PDF generator to make a PDF file out of the jp object. Then forward it to client 
+2

나는 이해할 수 없다. reportCollection은 어디에서 초기화 되었습니까? –

+0

@StefanosKargas 이것은 아주 오래된 질문 및 답변입니다. 문제가 있으면 새로운 질문을 올리십시오. – medopal

관련 문제