日期:2014-05-20 浏览次数:20867 次
ReportClientDocument clientDoc = rptAppFactory.openDocument(oInfoObject,0,Locale.ENGLISH);
// Set report parameters.
Fields paramCollection = clientDoc.getDataDefinition().getParameterFields();
// Set Matrix URL
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(0).getName(), webAppServer);
// Set session cookie for Matrix authentication
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(1).getName(), reportSession);
// Clear Matrix username
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(2).getName(), "");
// Clear Matrix password
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(3).getName(), "");
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(4).getName(), rptParam);
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(5).getName(), "");
//strClient为String类型,保存用户已输入的客户名
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(6).getName(),strClient);
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(7).getName(), "");
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(8).getName(), "");
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(9).getName(), "");
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue("", paramCollection.getField(10).getName(), "");
// Pass the report to the viewer
CrystalReportViewer viewer = new CrystalReportViewer();
viewer.setEnterpriseLogon(es);
viewer.setName(rptParam);
viewer.setOwnForm(true);
viewer.setOwnPage(true);
viewer.setPrintMode(CrPrintMode.PDF);
// Set the source for the viewer to the client documents report source
viewer.setReportSource(clientDoc.getReportSource());
viewer.setParameterFields(paramCollection );
viewer.setEnableParameterPrompt(false);
viewer.setReuseParameterValuesOnRefresh(false);
/*这个if语句是从网上看的,说是要刷新。加了话,第一页加载时,报错:缺少参数值。 如果不加,可以显示第一页,点击下一页,错误代码:com.crystaldecisions.sdk.occa.report.lib.ReportSDKParameterFieldException: The types of the parameter field and parameter field current values are not compatible.---- Error code:-2147213303 Error code name:invalidParameterField */
if(session.getAttribute("refresh")==null){
viewer.refresh();
session.setAttribute("refresh","true");
}
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), out);