JasperReport ตัวอย่างการใช้งาน


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();
}

คำสำคัญ (Tags): #jasperreport
หมายเลขบันทึก: 119263เขียนเมื่อ 13 สิงหาคม 2007 14:49 น. ()แก้ไขเมื่อ 19 มิถุนายน 2012 19:28 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (1)

ขอคุณครับ สำหรับคำแนะนำ

มีเรื่องถามครับ แล้วถ้าแสดงที่ Client side จะต้องทำอย่างไรบ้างครับ

พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท