jasper-reports
記入レポート
サーチ…
パラメーター
| パラメーター | カラム |
|---|---|
| ジャスパープリント | 所望のフォーマットにエクスポートすることができるフィルプロセスの出力 |
| reportTemplate | コンパイルされたデザインファイル.jasper |
| パラメーター | 定義されている場合、 $P{key}によってレポート内の参照になることができるパラメータMapは 、 |
| 情報源 | net.sf.jasperreports.engine.JRDataSource |
| 接続 | データベース接続java.sql.Connection |
IDE(統合開発環境)
JasperSoft Studio
レポートを記入するためにデータソースまたはデータベース接続が必要な場合は、[データアダプタの作成]を選択して[データアダプタ]を右クリックして、リポジトリエクスプローラでデータアダプタを作成します。
[ プレビュー ]タブを選択してプレビューモードに入ります(存在する必要のあるエラーはありません)
目的のデータソースを選択します(データソースが不要な場合は、[空のレコードを1つ]
必要に応じてパラメータを設定する
緑色の矢印「レポートを実行する」をクリックしてレポートを入力します。
Javaを使用して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);
データソースがないと、未使用の詳細バンド
// 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
