请问水晶报表如何传递参数? 如下代码中,在导出pdf前如何传递参数!

newhfy 2005-02-23 04:42:30
<%@ page errorPage = "errorPage.jsp" %>
<%@ page session="true"%>
<%@ page contentType = "text/html; charset=UTF-8" %>
<%@ page import= "java.net.*,
java.util.*,
java.io.*,
javax.servlet.*,
javax.servlet.http.*,
com.crystaldecisions.sdk.occa.report.application.*,
com.crystaldecisions.sdk.occa.report.lib.ByteArray.*,
com.crystaldecisions.sdk.occa.report.exportoptions.*,
com.crystaldecisions.sdk.occa.report.lib.*"
%>

<%
String reportName = (String) session.getAttribute("reportName");
String reportDirectory = "F:\\bea\\user_projects\\mydomain\\applications\\DefaultWebApp\\";

ReportClientDocument clientDoc = new ReportClientDocument();

try {
String rasServerName = "127.0.0.1"; // Localhost
clientDoc.setReportAppServer(rasServerName);

} catch(ReportSDKException e) {
out.println("An error has occurred setting the ReportClientDocument's ReportAppServer.<BR>");
out.println(e);
}

try {
clientDoc.open(reportDirectory + reportName, OpenReportOptions._openAsReadOnly);

} catch(ReportSDKException e) {
out.println("Report could not be opened. Please check that the report is in the same directory or that the value of the ReportName is correct.<BR>");
out.println(e);
}


PrintOutputController poController;

try {
String temp = request.getParameter("format").trim();
if (null != temp) {
session.setAttribute("formatType", temp);
}

String destType = request.getParameter("type");
String strExt = "";
String strMime = "";
poController = clientDoc.getPrintOutputController();

ByteArrayInputStream byteIS = (ByteArrayInputStream) poController.export(ReportExportFormat.from_int(formatType));
strExt = ".pdf";
strMime = "application/pdf";
byte byteArray[] = new byte[byteIS.available()];

int x = byteIS.read(byteArray, 0, byteIS.available());

response.reset();
response.setContentType(strMime);

if (destType.equals("file")) {
response.setHeader("Expires", "0");
response.addHeader("Content-disposition", "attachment; filename=exported" + strExt);
} else {
response.addHeader("Content-disposition", "inline; filename=exported" + strExt);
}
response.getOutputStream().write(byteArray);

} catch (Exception e) {
out.println("An error has occurred while exporting the report.<BR>" + e.toString());
out.println(e);
}

%>
...全文
67 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
lihongxing2002 2005-07-17
up
回复
delbrueck 2005-03-07
先传递参数再导出阿。
回复
发帖
Java EE
创建于2007-09-28

6.6w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2005-02-23 04:42
社区公告
暂无公告