lib ที่ใช้
jasperreports-1.3.4.jar
commons-beanutils-1.7.jar
commons-collections-2.1.jar
commons-digester-1.7.jar
commons-javaflow-20060411.jar
commons-logging-1.0.2.jar
เราต้องสร้างรูปแบบรายงานขึ้นมาก่อน ซึ่งจะใช้ *.jrxml
เช่น HelloReportWorld.jrxml
ตัวอย่าง
String reportSource = "./report/templates/HelloReportWorld.jrxml";
String reportDest = "./report/results/HelloReportWorld.html";
Map<String, Object> params = new HashMap<String, Object>();
try
{
JasperReport jasperReport =
JasperCompileManager.compileReport(reportSource);
JasperPrint jasperPrint =
JasperFillManager.fillReport(
jasperReport, params, new JREmptyDataSource());
JasperExportManager.exportReportToHtmlFile(
jasperPrint, reportDest);
JasperViewer.viewReport(jasperPrint);
}
catch (JRException ex)
{
ex.printStackTrace();
}
ขอคุณครับ สำหรับคำแนะนำ
มีเรื่องถามครับ แล้วถ้าแสดงที่ Client side จะต้องทำอย่างไรบ้างครับ