要使用润乾报表在javaweb的jsp中显示,即可以通过输入参数来查询数据库对应的信息要修改E:\项目\WEB-INF\report中的reportConfig.xml中的jdbc的配置信息。
<!--JDBC连接配置 begin-->
<jdbc-ds-configs>
<jdbc-ds-config>
<name>mysql</name>
<db-type>MYSQL</db-type>
<connection-url>jdbc:mysql://192.168.0.15:3306/gplatform</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>gem123456</password>
<db-charset>gbk</db-charset>
<client-charset>gbk</client-charset>
<extend-properties></extend-properties>
</jdbc-ds-config>
</jdbc-ds-configs>
在润乾报表的数据源中配置数据源。
新建报表后通过配置的数据集,然后选择对应数据集进行编辑。在检索条件中填写上
(?=" " orozap_assetnum.num =? )
and (?="" or ozap_assetnum.person =? ) and (?=" " orozap_assetnum.situation =? ) and (?=" " or ozap_assetnum.firstTime =? ) and (?=" " orozap_assetnum.nowLogin =? ) and (?=" " or ozap_assetnum.nowBad =? )and (?=" " or ozap_assetnum.checkSituation =? ),既可以实现多个参数的输入为空时查找所有的记录,?要在参数中按照顺序进行添加参数。但要先在配置中的参数先配置所需要的参数(在报表中预览时可以输入对应的参数)。
在属性中的报表属性中配置分页选择按行分页。填写每页显示的行数。即可以分页显示。但在报表的预览功能无法查看分页。
num.jsp(填入要查询字段的表单),提交时发送给action后的url处理,
<%@ pageimport="java.util.Calendar"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ includefile="/oz/includes/taglibs.jsp"%>
<%@ includefile="/3rd/runqian/includes/reportHeader.jsp"%>//引入reportHeader.jsp在这个页面可以放置上一页、下一页等标签。
<div id="paramDiv"style="padding:0px 80px; border-bottom: 1px solid #CCC;">
<form id="ozForm"action="<oz:contextPath/>/3rd/runqian/simpleViewReport.jsp"target="reportFrame" οnsubmit="setArg()">
<tablealign="left">
<tr>
<td><tablestyle="width: 80%" class="oz-form-table">
<trclass="oz-form-emptyTR" style="height: 10;">
<tdwidth="150"></td>
<tdwidth="250"></td>
<tdwidth="150"></td>
<tdwidth="250"></td>
</tr>
<tr>
<tdclass="oz-form-label">资产编号:</td>
<tdclass="oz-property">
<input type="text"name="num" id="num" value="">
</td>
<tdclass="oz-form-label">使用人:</td>
<tdclass="oz-property">
<input type="text"name="person" id="person" value="">
</td>
</tr>
<tr>
<tdclass="oz-form-label">第一次使用时间:</td>
<tdclass="oz-property">
<inputtype="text" name="firstTime" id="firstTime"value="">
</td>
<tdclass="oz-form-label">现状:</td>
<tdclass="oz-property">
<inputtype="text" name="situation" id="situation"value="">
</td>
</tr>
<tr>
<tdclass="oz-form-label">登记状态:</td>
<tdclass="oz-property">
<inputtype="text" name="nowLogin" id="nowLogin"value="">
</td>
<tdclass="oz-form-label">报废状态:</td>
<tdclass="oz-property">
<inputtype="text" name="nowBad" id="nowBad"value="">
</td>
</tr>
</table>
<inputtype="hidden" name="req" value="num.raq">
</td>
</tr>
<tr>
<tdvalign="top" align="right" style="padding:3px;">
<inputtype="submit" width="62" value="查询"class="oz-form-button"></input>
//submit不要设置name属性要不然提交后无法使用下一页等标签
</td>
</tr>
</table>
</form>
</div>
<oz:organizeJs/>
<scripttype="text/javascript">
functionsetArg() {
varcurrpage=reportFrame.report1_getCurrPage()+1;
varnum=$("#num").val();
varperson=$("#person").val();
varfirstTime=$("#firstTime").val();
varsituation=$("#situation").val();
varnowLogin=$("#nowLogin").val();
varnowBad=$("#nowBad").val();
}
</script>
<oz:js extend="true">
jQuery(function(){//设置num.jsp默认一加载时就自动查讯一下报表,先把表单序列化
varsrc = "<oz:contextPath/>/3rd/runqian/simpleViewReport.jsp";
varformData =jQuery.param(jQuery("#ozForm").serializeArray());
console.log(formData);
jQuery("#reportFrame").attr("src",src+"?"+formData);
});
console.log($("#reportFrame"));
</oz:js>
<%@ includefile="/3rd/runqian/includes/reportFooter.jsp"%>
reportFooter.jsp页面
<%@ pagecontentType="text/html;charset=UTF-8"%>
<%@ includefile="/oz/includes/taglibs.jsp"%>
<oz:ui templete="form"datePicker="true" toolbar="true"/>
<html>
<head>
<oz:css/>
</head>
<body class="oz-body">
<div id="functionBar">
<oz:toolbaraction="" searchButton="none">
<oz:tbSeperator/>
<oz:tbButtonid="btnBack"></oz:tbButton>
<oz:tbButtonid="btnExportExcel" text="导出Excel"icon="oz-icon-1503" οnclick="reportFrame.report1_saveAsExcel()"></oz:tbButton>
<oz:tbButtonid="btnExportPdf" text="导出Pdf"icon="oz-icon-1509"οnclick="reportFrame.report1_saveAsPdf()"></oz:tbButton>
<oz:tbButtonid="last" text="上一页" icon="oz-icon-1509" οnclick="reportFrame.report1_toPage(reportFrame.report1_getCurrPage()-1)"></oz:tbButton>
<oz:tbButtonid="next" text="下一页" icon="oz-icon-1509"οnclick="reportFrame.report1_toPage(reportFrame.report1_getCurrPage()+1)"></oz:tbButton>
<oz:tbButtonid="first" text="第一页" icon="oz-icon-1509"οnclick="reportFrame.report1_toPage(1)"></oz:tbButton>
<oz:tbButtonid="last" text="最后一页" icon="oz-icon-1509"οnclick="reportFrame.report1_toPage(reportFrame.report1_getTotalPage())"></oz:tbButton>
<oz:tbSeperator></oz:tbSeperator>
</oz:toolbar>
</div>
simpleViewReport.jsp页面
<%@ pagecontentType="text/html;charset=UTF-8"%>
<%@ includefile="/oz/includes/taglibs.jsp"%>
<%@ taglib uri="http://www.oz.com.cn/tags/report"prefix="report" %>
<%@ pageimport="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ pageimport="com.runqian.report4.usermodel.Context"%>
<html>
<head>
<scripttype="text/javascript">
var_editorBorderLeft = "1px solid red"; //填报编辑框左边框
var_editorBorderTop = "1px solid red"; //填报编辑框上边框
var_editorBorderRight = "1px solid red"; //填报编辑框右边框
var_editorBorderBottom = "1px solid red"; //填报编辑框下边框
var_editingRowBackColor = "#d1f2fe"; //填报编辑行背景色,设为空值则不标记当前编辑行
var_calendarMainBackColor = "#fa8072"; //填报下拉日历主面板色
var_calendarWeekColor = "#FFFFFF"; //填报下拉日历周文字色
var_calendarDayColor = "#000040"; //填报下拉日历日期文字色
var_calendarDayBackColor = "#ffe4e1"; //填报下拉日历日期面板色
</script>
</head>
<body class=""style="margin: 0;">
<%
Stringreport = request.getParameter( "req" );
if(report== null){
%>
报表参数错误,请检查req的值。
<%
}else{
%>
<%
StringreportFileHome=Context.getMainDir();
//保证报表名称的完整性
intiTmp = 0;
if((iTmp = report.lastIndexOf(".raq")) <= 0 ){
report= report + ".raq";
iTmp= 0;
}
//转换参数
StringBufferparam=new StringBuffer();
EnumerationparamNames = request.getParameterNames();
if(paramNames!=null){
while(paramNames.hasMoreElements()){
StringparamName = (String) paramNames.nextElement();
StringparamValue=request.getParameter(paramName);
if(paramValue!=null){
//把参数拼成name=value;name2=value2;.....的形式
param.append(paramName).append("=").append(paramValue).append(";");
}
}
}
//导出名称定义
StringsaveAsName = request.getParameter( "saveAsName" );
if(saveAsName == null || saveAsName.trim().length() == 0 ) saveAsName = report;
Stringsscale = request.getParameter( "scale" );
doublescale = 100;
try{scale = Double.parseDouble( sscale );}catch( Exception e ) {}
scale= scale / 100;
sscale= String.valueOf( scale );
%>
//配置文件
//scale,params, saveAsName分别表示如下信息
//scale=1.0,
//params=num=;person=;firstTime=;situation=已申领;nowLogin=;nowBad=正在报废;checkSituation=;req=num.raq;"
//saveAsName="num.raq"
<report:html name="report1" reportFileName="<%=report%>"
scale="<%=sscale%>"
params="<%=param.toString()%>"
excelPageStyle="0"
needScroll="no"
scrollWidth="100%"
scrollHeight="400"
scrollBorder=""
selectText="yes"
promptAfterSave="yes"
funcBarLocation=""//funcBarLocation=”top”时默认显示在报表上面显示标签
saveAsName="<%=saveAsName%>"
backAndRefresh="no"
needSaveAsExcel="yes"
needSaveAsPdf="yes"
needPrint="true"
needPageMark="yes"
width="1500"//设置为-1时就不会分页,和把needScroll=”no”时也不会分页
height="1000"
displayNoLinkPageMark="yes"
pageMarkLabel="页号{currpage}/{totalPage}"
/>
<div id=div1style="width:100%;height:100%"></div>
<oz:js jsId="jquery"/>
<scripttype="text/javascript">
functionmyResize() {
varscrolldiv = document.getElementById( "report1_scrollArea" );
varscrollContentdiv=document.getElementById( "report1_contentdiv" );
varscrollContentdivH=scrollContentdiv.scrollHeight;
$("#div1").prev().hide();
if(scrolldiv != null ) {
vardiv1 = document.getElementById( "div1" );
div1.style.display= "";
varh = div1.offsetHeight;
h-= getHeightX( document.body );
h=h+scrollContentdivH; //调整Ie和google下面的滚动条问题
scrolldiv.style.height= h;
_resizeScroll();
div1.style.display= "none";
}
}
$(window).resize(myResize);
$(myResize);
document.report_turnPageForm.action="<oz:contextPath/>/3rd/runqian/simpleViewReport.jsp";
</script>
<%}%>
</body>
</html>
如果想要在前端页面中取出某一列的数据可以加name="xxx"属性,前端页面就可以获取整列的数据了。