查看使用受管理 RAS 服务器的报表

来源:互联网 发布:盈峰环境科技集团java 编辑:程序博客网 时间:2024/05/18 09:04

此实例说明如何使用查看器标记库来显示使用从受管理报表应用程序服务器中所获得报表源的报表。

查看使用受管理 RAS 服务器的报表
  1. 导入相应的类和库

    <%@ taglib uri="/crystal-tags-reportviewer.tld" prefix="crviewer" %>

    <%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>

    <%@ page import="com.crystaldecisions.sdk.framework.ISessionMgr" %>

    <%@ page import="com.crystaldecisions.sdk.framework.IEnterpriseSession" %>

    <%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>

    <%@ page import="com.crystaldecisions.sdk.occa.managedreports.*" %>

    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObject" %>

    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoObjects" %>

    <%@ page import="com.crystaldecisions.sdk.occa.infostore.IInfoStore" %>

    <%@ page import="com.crystaldecisions.sdk.occa.report.reportsource.IReportSourceFactory2" %>



  2. 登录到 Crystal Enterprise 并获取 InfoStore 对象。

    在本例中,使用了默认管理员帐户来登录到与应用程序服务器运行在同一计算机上的 Crystal Enterprise 安装。

    <%

    IEnterpriseSession es = CrystalEnterprise.getSessionMgr().logon("administrator", "", "localhost", "secEnterprise");

    ????IInfoStore infoStore = (IInfoStore) es.getService("", "InfoStore");



  3. 查询想要查看的报表。

    IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");

    ????IInfoObject report = (IInfoObject) infoObjects.get(0);



  4. 为检索到的报表创建一个 RAS 报表源。

    IReportSourceFactory2 reportFactory = (IReportSourceFactory2) es.getService ("", "RASReportFactory");

    ????Object reportSource = reportFactory.createReportSource(report, request.getLocale());



  5. 将 ReportSource 对象缓存在会话变量中。

    这样,查看器将能够检索到该对象。

    session.setAttribute("ReportSource", reportSource);

    %>



  6. 创建一个指定查看器名称、报表源类型和报表源变量的 viewer 标记。

    在本例中,报表源类型为 reportApplicationServer,并且报表源变量是指您在其中存储了 ReportSource 对象的会话变量。

    <html>

    <body>

    <crviewer:viewer viewerName="CrystalViewer" reportSourceType="reportApplicationServer" reportSourceVar="ReportSource" />

    </body>

    </html>



    注意: ???本例中不需要 report 标记,因为报表源已缓存在会话变量中,并且不需要由查看器检索。

原创粉丝点击