範例一:使用 DHTML 檢視器以檢視報表

以下範例是一個簡單的 JSP 頁面,示範如何使用 DHTML 報表頁面檢視器來顯示簡單的報表。

注意:    本範例所使用的報表不包含在教學課程中。

viewreport.jsp

<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer" %>

<%@ page import="com.crystaldecisions.reports.sdk.ReportClientDocument" %>

<%

    Object reportSource = session.getAttribute("reportSource");

    if (reportSource == null)

    {

        String report = "/reports/sample.rpt";

        ReportClientDocument reportClientDoc = new ReportClientDocument();

        reportClientDoc.open(report, 0);

        reportSource = reportClientDoc.getReportSource();

        session.setAttribute("reportSource", reportSource);

    }

    CrystalReportViewer viewer = new CrystalReportViewer();

    viewer.setReportSource(reportSource);

    viewer.setOwnPage(true);

    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

%>



Business Objects
http://www.taiwan.businessobjects.com/
支援服務
http://www.businessobjects.com/services/support/