天天看點

潤乾報表分頁

要使用潤乾報表在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"

         scroll

         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"屬性,前端頁面就可以擷取整列的資料了。