サブレポートの作成
こちらを参考にiReport&JasperReportsでサブレポートを作成していきたいと思います。
サブレポートの設定
[ウィンドウ]⇒パレットを選択し、サブレポートをドラッグしてきます。


今回は新しいレポートを選択します。既に作成済みの場合は[既存のレポートを使用]を選択してください。
レイアウトと保存名とパス指定以外デフォルト状態で[次へ]を押下します。







完了を押下するとサブレポートが出来上がります。

必要に応じてサブレポートの言語を変更します。

メインレポートからサブレポートにパラメータを渡したい場合、メインレポートからサブレポートのフィールドを選択し、プロパティにあるパラメータから設定することでできます。



メインレポートとは違った名前の指定や式を用いて変換することもできるみたいです。
データソースをメインレポート⇒サブレポートに渡す場合
今回はデータソースをCollection型データを渡すようにします。
まず、メインレポートにてJRBeanCollectionDataSourceをインポートします。
レポートを右クリック⇒プロパティ⇒インポート⇒追加の順にクリックし、下記の情報を入力します。
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource




次にメインレポートにてサブレポートのフィールドを選択し、Connection typeをUse a datasource expessionを選択します。

データソース文字列に下記文字を挿入します。
new JRBeanCollectionDataSource($F{フィールド名})
パラメータ⇒フィールド名⇒プロパティを開き、パラメータクラスに「java.util.Collection」を選択します。

あとはJAVA側でパラメータにコレクション型を渡せばOKです。
例)
ArrayList<ArrayList<String>> サブレポートのデータソース = new ArrayList<ArrayList<String>>();
ArrayList<String> サブレポートのフィールド = new ArrayList<String>();
サブレポートのフィールド.add("test");
サブレポートのフィールド.add("test2");
サブレポートのフィールド.add("test3");
サブレポートのデータソース.add(サブレポートのフィールド);// レポートのパラメータを作成する
HashMap parameters = new HashMap<String, String>();//データソースの作成
dataSource = new JRBeanCollectionDataSource(メインレポートのデータソース);//サブレポートのデータソースセット
parameters.put("フィールド名", サブレポートのデータソース);//出力処理
JasperPrint print = JasperFillManager.fillReport(テンプレートパス+ファイル名, parameters, メインレポートのデータソース);<br /><br />// PDFファイルへ出力する
//直接出力の場合
//JasperExportManager.exportReportToPdf(print,"pdf/output/sample_report2.pdf");
//byteにて格納する場合
byte[] bytes = JasperExportManager.exportReportToPdf(print);
これでサブレポートが出来ると思います。