Java を使用して JasperReport にデータを渡そうとしています。ただし、テーブル データは非常に動的であり、SQL クエリをレポートに渡すことができません。これについて何か考えはありますか?オブジェクト型の 2D 配列があり、そこにすべてのデータがあります。どうすればそれを渡すことができますか?
ConnectionManager con = new ConnectionManager();
con.establishConnection();
String fileName = "Pmc_Bill.jrxml";
String outFileName = "OutputReport.pdf";
HashMap params = new HashMap();
params.put("PName", pname);
params.put("PSerial", psrl);
params.put("PGender",pgen);
params.put("PPhone",pph);
params.put("PAge",page);
params.put("PRefer",pref);
params.put("PDateR",dateNow);
try {
JasperReport jasperReport = JasperCompileManager.compileReport(fileName);
if(jasperReport != null )
System.out.println("so far so good ");
// Fill the report using an empty data source
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JRTableModelDataSource(tbl.getModel()));//con.connection);
try{
JasperExportManager.exportReportToPdfFile(jasperPrint, outFileName);
System.out.printf("File exported sucessfully");
}catch(Exception e){
e.printStackTrace();
}
JasperViewer.viewReport(jasperPrint);
} catch (JRException e) {
JOptionPane.showMessageDialog(null, e);
e.printStackTrace();
System.exit(1);
}