on 03-05-2009 9:21 AM
刚刚接触crystal report,在2008试用版上测试开发的时候,在sap社区下的例子:
<%@ page import="com.crystaldecisions.report.web.viewer.CrystalReportViewer,
com.crystaldecisions.sdk.occa.report.application.OpenReportOptions,
com.crystaldecisions.sdk.occa.report.application.ReportClientDocument"
%><%
String reportPath;
Object reportSource;
ReportClientDocument reportClientDocument;
reportPath = request.getParameter("report_path");
reportClientDocument = new ReportClientDocument();
reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);
reportClientDocument.open(reportPath, OpenReportOptions._openAsReadOnly);
reportSource = reportClientDocument.getReportSource();
session.setAttribute("ReportSource", reportSource);
reportClientDocument.close();
response.sendRedirect("viewer_frame.html");
%>
但是在本地编译的时候,老是报错
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /Java_CRJ12_Web_View/java_crj12_web_view.jsp
Generated servlet error:
D:\Tomcat 5.0\org\apache\jsp\Java_005fCRJ12_005fWeb_005fView\java_005fcrj12_005fweb_005fview_jsp.java:71: cannot resolve symbol
symbol : variable inprocConnectionString
location: class com.crystaldecisions.sdk.occa.report.application.ReportClientDocument
reportClientDocument.setReportAppServer(ReportClientDocument.inprocConnectionString);
^
1 error
类com.crystaldecisions.sdk.occa.report.application.ReportClientDocument所在的jar包rasapp.jar已经引入
gytest,你有用到RAS服务器吗?
如果没用到,可以直接调用CR Java SDK,不用RAS SDK。
String report = "/reports/sample.rpt";
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(report, 0);
Object reportSource = reportClientDoc.getReportSource();
session.setAttribute("reportSource", reportSource);
我没有在API里找到ReportClientDocument.inprocConnectionString 这个String,你的程序报编译错误有可能确实在SDK包里找不到这个这个参数。
如果用到了RAS服务器,且你的report是unmanaged report的话,就调用unmanaged RAS SDK,如下:
// Modify this path to the location of the report on your system.用
代替下面path中的\
String path = "C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Samples\en\Reports\DemonstrationWorld Sales Report.rpt";
// Create a new Report Application Session.
ReportAppSession ra = new ReportAppSession();
// Create a RAS service.
ra.createService("com.crystaldecisions.sdk.occa.report.application.ReportClientDocument");
// Set the RAS server to be used for the service.
ra.setReportAppServer("localhost");
// Initialize RAS.
ra.initialize();
// Create the ReportClientDocument object.
ReportClientDocument clientDoc = new ReportClientDocument();
// Set the RAS server to be used.
clientDoc.setReportAppServer(ra.getReportAppServer() );
// Open the report, and set the open type to Read Only.
clientDoc.open(path, OpenReportOptions._openAsReadOnly);
另外,RAS SDK的话,至少需要引入这些包:
rasapp.jar
rascore.jar
serialization.jar
//log4j.jar
//logging.jar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.