0
private void txtPrintActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
JasperCompileManager.compileReportToFile("../report/report2.jrxml");
JasperPrint jasperPrint=JasperFillManager.fillReport("../report/report2.jasper",new HashMap(),new JRTableModelDataSource(tblStock.getModel()));
JasperViewer jasperviewer=new JasperViewer(jasperPrint);
jasperviewer.setVisible(true);
}
catch(Exception e) {
System.out.println("Exception in generating report,generateReport() of JasperReportGenerator:"+e);
}
}
用此代碼生成的Jasper報告不顯示JTable ..無法將JTable傳遞給Jasper報告
代碼中的JTable在哪裏?你是否使用JTable作爲報告的模型? –
你可以看看[TableModel Data Source sample](http://jasperreports.sourceforge.net/sample.reference/datasource/index.html#tablemodeldatasource)和[用JRTableModelDataSource填寫報告](http://community.jaspersoft .com/node/508028)post –
jtable是tblstock(jtable的變量名),它存在於同一個java文件中.jtable中填充了數據庫中的數據..我已經提到這些鏈接..但是找不到解決方案.. – user1630555