此实例说明如何使用查看器标记库来显示使用从受管理报表应用程序服务器中所获得报表源的报表。
查看使用受管理 RAS 服务器的报表
- 导入相应的类和库
<%@ 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" %> - 登录到 Crystal Enterprise 并获取 InfoStore 对象。
在本例中,使用了默认管理员帐户来登录到与应用程序服务器运行在同一计算机上的 Crystal Enterprise 安装。
<%IEnterpriseSession es = CrystalEnterprise.getSessionMgr().logon("administrator", "", "localhost", "secEnterprise");????IInfoStore infoStore = (IInfoStore) es.getService("", "InfoStore"); - 查询想要查看的报表。
IInfoObjects infoObjects = infoStore.query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='World Sales Report'");????IInfoObject report = (IInfoObject) infoObjects.get(0); - 为检索到的报表创建一个 RAS 报表源。
IReportSourceFactory2 reportFactory = (IReportSourceFactory2) es.getService ("", "RASReportFactory");????Object reportSource = reportFactory.createReportSource(report, request.getLocale()); - 将 ReportSource 对象缓存在会话变量中。
这样,查看器将能够检索到该对象。
session.setAttribute("ReportSource", reportSource);%> - 创建一个指定查看器名称、报表源类型和报表源变量的 viewer 标记。
在本例中,报表源类型为 reportApplicationServer,并且报表源变量是指您在其中存储了 ReportSource 对象的会话变量。
<html><body><crviewer:viewer viewerName="CrystalViewer" reportSourceType="reportApplicationServer" reportSourceVar="ReportSource" /></body></html>注意: ???本例中不需要 report 标记,因为报表源已缓存在会话变量中,并且不需要由查看器检索。
本文介绍如何通过受管理的报表应用程序服务器(RAS)显示报表。通过登录到Crystal Enterprise并利用特定API,可以查询和创建报表源,最终通过查看器显示出来。
100

被折叠的 条评论
为什么被折叠?



