0

私は使っている

ファイル名.jrxml

で簡単なレポートを作成するファイル

itext4.8.0

正常に動作していますが、このようなパラメーターを渡しています。

$P{ユーザーID}]

今、私は同じものを使いたい

ファイル名.jrxml

Javaコードでこれを達成するにはどうすればよいですか? 私の主な関心事は、ireport でレポートを実行しているときに ireport のようにパラメーター値を渡す方法です。パラメーターのポップアップを開き、値を入力しています。

注: - レポートとの接続を渡したくありません。

4

2 に答える 2

1

このブログエントリで解決策を見つけました

于 2012-11-26T05:19:35.093 に答える
0

jasperreportエンジンをダウンロード

final Map<String,Object> parameter = new HashMap<String, Object>();
parameter.put("userId", 1l);
JasperFillManager.fillReport("filename.jasper", parameter, getData());

// set your own params for this method
public JRDatasource getData() { 
  // initialize a collection of Objects
  // Oh yes the query
  final Query query = getQuery("from SomeObject");
  final List<SomeObject> collection = (List<SomeObject>)query.list();
  return new JRBeanCollectionDataSource(collection);
}

別の可能性

JasperFillManager.fillReport(jasperReport, parameter, connection);
于 2012-11-22T17:38:40.647 に答える