1)设计:设计报告的想法几乎相同。安装插件后 make new->report 并开始设计。完成后选择预览,iReport 将编译您的报告,生成一个 .jasper 文件。
2)执行:编写代码以传递数据并从您的java代码运行.jasper 类似的东西:
JasperPrint print=null;
ResultSet rs=null;
try {
Statement stmt = (Statement) myConnection.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE,//Default either way
ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery("select * from Table");
} catch (SQLException sQLException) {
}
try {
print = JasperFillManager.fillReport(filename, new HashMap(), new JRResultSetDataSource(rs));
} catch (JRException ex) {
}
try{
JRExporter exporter=new net.sf.jasperreports.engine.export.JRPdfExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, pdfOutFileName);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.exportReport();
}.......