jasper-reports
보고서 채우기
수색…
매개 변수
| 매개 변수 | 기둥 |
|---|---|
| 재빠른 인쇄 | 원하는 형식으로 내보낼 수있는 채우기 프로세스의 출력 |
| reportTemplate | 컴파일 된 디자인 파일 .jasper |
| 매개 변수들 | 정의 된 경우 매개 변수 Map 은 $P{key} 의해 보고서 내에서 참조가 될 수 있습니다. |
| 데이터 소스 | net.sf.jasperreports.engine.JRDataSource |
| 연결 | 데이터베이스 연결 java.sql.Connection |
IDE (통합 개발 환경)
재스퍼 소프트 스튜디오
보고서를 채우기 위해 데이터 소스 또는 데이터베이스 연결이 필요한 경우 "데이터 어댑터 생성"을 선택하여 "데이터 어댑터"를 마우스 오른쪽 버튼으로 클릭하여 리포지토리 탐색기에서 데이터 어댑터를 생성하십시오.
미리 보기 탭을 선택하여 미리 보기 모드에 들어갑니다.
원하는 데이터 소스 선택 (데이터 소스가 필요없는 경우 "빈 레코드 하나 선택"
매개 변수를 원하는대로 설정하십시오.
녹색 화살표 "보고서 실행"을 클릭하여 보고서를 작성하십시오.
자바를 사용하여 JasperReport 템플릿 채우기
공통 요구 사항
데이터가 표시되는 방법에 관계없이 모든 보고서는 보고서 템플리트 및 매개 변수 맵의 경로를 사용합니다. 변수는 다음의 모든 예제에서 사용됩니다.
// Parameters passed into the report.
Map<String, Object> parameters = new HashMap<>();
// Arbitrary parameter passed into the report.
parameters.put("KEY", "Value");
// The compiled report design.
String path = "path/to/template.jasper";
.jrxml 파일을 사용하면 대부분의 상황에서 필요하지 않은 추가 컴파일 단계가 발생합니다. 보고서가 실행되기 전에 .jrxml 을 변경하기 위해 사용자 정의 소프트웨어를 작성하지 않은 경우 (예 : 열을 동적으로 추가 또는 제거). 후속 예에서와 같이 .jasper 파일을 사용하십시오.
데이터베이스 연결 사용
// Establish a database connection.
Connection connection = DriverManager.getConnection(url, username, password);
// Fill the report, get the JasperPrint that can be exported to desired format.
JasperPrint jasperPrint = JasperFillManager.fillReport(
path, parameters, connection);
사용자 지정 데이터 원본 사용
// Populate this list of beans as per your requirements.
List<Bean> beans = new ArrayList<>();
// Wrap the beans in a beans in a JRBeanCollectionDataSource.
JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(beans);
// Fill the report, get the JasperPrint that can be exported to desired format.
JasperPrint jasperPrint = JasperFillManager.fillReport(
path, parameters, datasource);
데이터 소스가 없으면 사용되지 않는 Detail Band
// Fill the report, get the JasperPrint that can be exported to desired format.
JasperPrint jasperPrint = JasperFillManager.fillReport(path, parameters);
데이터가 없으면
JasperReport요소의whenNoDataType="AllSectionsNoDetail"속성을 설정해야하며, 그렇지 않으면 빈 (빈) 보고서가 생성됩니다.
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow
