java如何使⽤⽔晶报表_Java操作⽔晶报表Java操作⽔晶报表DAO类: public static ResultSet getResultSet(final int scrollType) {
ResultSet resultSet = null;
String query = "";
Connection conn = Connection();
String sql = "select * from table1";
resultSet = ateStatement().executeQuery(sql);
} catch (Exception e) {
System.out.Message());
高级律师}
return resultSet;
}
Action类如下:
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
operatorName = Parameter("operatorName");
httpSession = Session();
boolean flag = this.ReportSourceInSession("reportSource", httpSession);
if (true) {
request.setAttribute("field", this.setOperator("operator", operatorName, ""));
return mapping.findForward("success");
王安石百科
} else
return mapping.findForward("error");
苏州阳光健身卡
}
public boolean ReportSourceInSession(String session_name,
HttpSession session) {
boolean flag = false;
try {
ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open("result.rpt", 0);
ResultSet resultSet = CrytalReport
.getResultSet(ResultSet.TYPE_SCROLL_INSENSITIVE);
String tableAlias = DatabaseController()
术尔泰
.getDatabase().getTables().getTable(0).getAlias(); DatabaseController().setDataSource(resultSet, tableAlias, "reportSource");
session.setAttribute(session_name, reportClientDoc
.getReportSource());
flag = true;
return flag;
} catch (Exception e) {
System.out.Message());
return flag;
}
}
JSP页⾯内容如下:
Result
Object reportSource = Attribute("reportSource"); CrystalReportViewer crViewer = new CrystalReportViewer(); crViewer.setOwnPage(true);
crViewer.setOwnForm(true);
crViewer.setReportSource(reportSource);
crViewer.setPrintMode(CrPrintMode.ACTIVEX);
crViewer.setParameterFields((Attribute("field")); crViewer.setEnableParameterPrompt(false);
crViewer.processHttpRequest(request, response, this
.getServletConfig().getServletContext(), null);
%>