java misc

1、jsp 導入excel

<%@page import="com.mycim.core.util.StringUtils"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page language="java"%>
<%@ taglib uri="struts-html" prefix="html"%>
<%@ taglib uri="struts-logic" prefix="logic"%>
<%@ taglib uri="struts-bean" prefix="bean"%>
<%@ taglib uri="mycim2" prefix="mycim2"%>
<html>
<head>
<title>Lot End Time</title>
<html:base />
<link rel="stylesheet" href="<%=request.getContextPath()%>/stylesheet/mycim2.css?version=${version}" type="text/css">
<script language="JavaScript" src="<%=request.getContextPath()%>/assets/js/jquery/jquery-1.11.3.js?version=${version}"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/function/function.js?version=${version}"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/function/reasoncode.js?version=${version}"></script>
</head>
<body>
<html:form action="/lotstependtime.do"  styleId="endtimeForm"  enctype="multipart/form-data">
<input name="impLotStepEndTimesJsonStr" type="hidden" value="${impLotStepEndTimesJsonStr}" >
<input name="errorMsg" type="hidden" value="${errorMsg}" >
<table width="800px">
<tr><td><div class="mytitle"><mycim2:contentDisplay id='LBS_LOT_ENDTIME' default='Lot End Time'/></div></td></tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td>
    <table width="100%" class="mytable">
        <tr>
        <td  bgcolor="#E8E8E8" >
             <fieldset id="fld1"><legend><mycim2:contentDisplay id="LBS_LOT_INFO" default="Lot Info"/></legend>
            <table width="100%" border="0" >
            <tr class="myfield">
                <td width="120px" nowrap><mycim2:contentDisplay id="LBL_LOT_ID" default="Lot ID" /></td>
                <td>
              	    <html:text property="lotId" readonly="false" styleClass="myfield" size="32"/>
              	    <mycim2:doSearch focus="lotId" type="LOT" callback='searchSubmit()'/>
                </td>
              	<td width="120px" class="myfield" nowrap align=left>
					<mycim2:contentDisplay id="LBL_CARRIER_ID" default="Carrier Id" />
				</td>
				<td class="myfield">
				    <html:text property="carrierId" readonly="false" styleClass="myfield" size="32"/>
					<mycim2:doSearch focus="carrierId|lotId" type="LOT_CARRIER" callback='searchSubmit()' />
				</td>
            </tr>
	        </table>
		    </fieldset>
		    <br>
		    
		    <!-- Import Excel -->
		    <fieldset id="fld2">
			<legend>
				<mycim2:contentDisplay id="LBL_DATA_IMPORT" default="Data Import" />
			</legend>
			<table width="100%">
				<tr nowrap>
					<td nowrap>
						<html:file property="formFile" />
						<input type="button" name="import" value="<mycim2:contentDisplay id="LBL_IMPORT"  default="Import"/>" onclick = "verifyAndSubmitImport()">
					</td>
					<td class="myfield" bgcolor="#E8E8E8" align="left">
						<a href="<%=request.getContextPath()%>/wip/endtime_import_template-version 1.xls"><mycim2:contentDisplay id="LBS_IMPORT_TEMPLATE" default="Import Template Download" /></a>
					</td>
				</tr>
		  </table>
		  </fieldset>
									
		  <fieldset id="fld3"><legend><mycim2:contentDisplay id="LBS_LOT_ENDTIME_LIST" default="Lot End Time List" /></legend>	
		  <table width="100%">	 
		  <thead> 		
          <tr align="center" class="myinnertable">
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_LOT_ID" default="Lot ID" /></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_PROCESS_ID" default="Process ID" /></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_ROUTE_SEQ" default="Route Seq." /></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_ROUTE_ID" default="Route ID"/></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_OPERATION_SEQ" default="Step Seq." /></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_OPERATION_ID" default="Step ID"/></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBL_END_TIME" default="End Time"/></td>
            <td nowrap width="15%"><mycim2:contentDisplay id="LBL_COMMENTS" default="Comments"/></td>
            <td nowrap width="5%"><mycim2:contentDisplay id="LBS_SET_BY" default="Set By"/></td>            
            <td nowrap width="5%"><mycim2:contentDisplay id="LBS_SET_DATE" default="Set Date"/></td>  
            <td nowrap width="5%"></td>                      
          </tr>
          </thead>
          
          <tbody>
          <logic:present name="lotStepEndTimeList">
			<logic:iterate id="item" name="lotStepEndTimeList"  indexId="seq">		         
          	<tr class="myinnertable2">		
	            <td nowrap class="myfield"><mycim2:write name="item" property="lotId" filter="true"/></td> 	            
	            <td nowrap class="myfield"><mycim2:write name="item" property="processId" filter="true"/></td> 	            
	            <td nowrap class="myfield"><mycim2:write name="item" property="routeSeq" filter="true"/></td> 	            
	            <td nowrap class="myfield"><mycim2:write name="item" property="routeId" filter="true"/></td>  
	            <td nowrap class="myfield"><mycim2:write name="item" property="operationSeq" filter="true"/></td> 	            	          			
	            <td nowrap class="myfield"><mycim2:write name="item" property="operationId" filter="true"/></td>
	            <td nowrap class="myfield"><mycim2:write name="item" property="endTime" filter="true"/></td>	
	            <td width="15%" class="myfield"><mycim2:write name="item" property="comments" filter="true"/></td>	
	            <td class="myfield" ><mycim2:write name="item" property="createUser" filter="true"/></td>
	            <td class="myfield" ><mycim2:write name="item" property="createTime" filter="true"/></td>
	            <td class="myfield" ><a href="javascript:doDelete('delete=Y&lotRrn=<mycim2:write name="item" property="lotRrn" filter="true"/>&endTimeRrn=<mycim2:write name="item" property="endTimeRrn" filter="true"/>')">
	            <img  height=16 src="<%=request.getContextPath()%>/img/delete.gif" width=16 border=0></a></td>
          	</tr>	
			</logic:iterate>
			</logic:present>
			</tbody>  
			
			</table>
			</fieldset>
		  
		   <FIELDSET><LEGEND><mycim2:contentDisplay id="LBS_LOT_ENDTIME_INFO" default="Lot End Time Info"/></LEGEND>
			<table width="100%">
			      <tr>
					  <td class="myfield"  width="120px" nowrap>
					  	<mycim2:contentDisplay id="LBL_PRODUCT_ID" default="Product Id"/>
					  </td>
					  <td  nowrap> 
					  	<html:text property="productId" size="32" styleClass="mylongreadonly" readonly="true" /> 
					  </td>
					  <td class="myfield"  width="120px" nowrap>
					  	<mycim2:contentDisplay id="LBL_PROCESS_ID" default="Process Id"/>
					  </td>
					  <td  nowrap> 
					  	<html:text property="processId" size="32" styleClass="mylongreadonly" readonly="true" />
					  	<html:hidden property="processRrn"/>
					  </td>
				  </tr>
		          <tr  class="myfield">
		            <td nowrap width="120px"><mycim2:contentDisplay id="LBL_ROUTE_ID" default="Route ID"/></td>
		            <td>
		              <html:text property="routeId" size="28" styleClass="myreadonly" readonly="true"/> 
		            </td>	
		            <td nowrap width="120px"><mycim2:contentDisplay id="LBL_OPERATION_ID" default="Operation ID"/></td>
		            <td>
		                <html:text property="operationId" size="32" /> 
		                <a href="javascript:doOpen('wip/showprocess.jsp?type=TREE_WITH_REWORK&processrrn=${lotStepEndTimeForm.processRrn}&productId=${lotStepEndTimeForm.productId}&processver=${lotStepEndTimeForm.processVersion}&executionRrn=0&routeid=routeId&oprid=operationId&returnid=returnStepNumber&routeSeq=routeSeq&operationSeq=operationSeq')">
            			<img height=16 src="<%=request.getContextPath()%>/img/search.gif" width=16 border=0></a>
            			<html:hidden property="returnStepNumber"/>	
		            </td>			            	            			            
		          </tr>
		          <tr class="myfield">
		            <td nowrap width="120px"><mycim2:contentDisplay default="Route Seq" id="LBL_ROUTE_SEQ"/></td>
		            <td>
		             	<input type="text" class="myreadonly" readonly="true" size="32" name="routeSeq" value="">
		            </td>
		            <td nowrap width="120px"><mycim2:contentDisplay default="Operation Seq" id="LBL_OPERATION_SEQ"/></td>
		            <td>
		             	<input type="text" class="myreadonly" readonly="true" size="32" name="operationSeq" value=""> 
		             	<input type="button" name="clear" style="margin-left:-3px;width:49px;" value="<mycim2:contentDisplay id="LBS_CLEAR" default="Clear"/>" onClick="doClean();">
		            </td>			            	            			            
		          </tr>
		          
		          
					<%-- <tr class="myfield">
		                <td nowrap width="120px"><mycim2:contentDisplay id="LBL_DEPARTMENT_ID" default="Dept ID"/></td>
		                <td>
		                    <mycim2:select property="department" styleClass="myselect3" onchange="getUsers()">
		                        <mycim2:option type="department" default="" optionalFlag="Y"/>
							</mycim2:select>														
		                </td>
		                <td width="120px"><mycim2:contentDisplay id="LBL_EXT_ID" default="Ext No."/></td>
						<td><html:text property="deptExt" size="32" maxlength="32"/></td>
		            </tr> --%>
		            <tr>
		                <%--  
		                <td width="120px"><mycim2:contentDisplay id="LBL_RESPONSIBILITY" default="Responsibility"/></td>
						<td>
						    <mycim2:select  property="userId" styleClass="myselect3">	
						        <%String type="ALL_USER|"+((Long)session.getAttribute("facility")).longValue();%>
						        <mycim2:option type="<%=type%>" default=""/>
							</mycim2:select>
							<!-- <input type="hidden" id="userRrn" name="userRrn">  -->
						</td>
						 --%>
		                <td width="120px"><mycim2:contentDisplay id="LBL_END_TIME" default="End Time"/></td>
						<td><html:text property="endTime" size="32" maxlength="32"/></td>
		            </tr>
		            <tr class="myfield">
		                <td width="120px"><mycim2:contentDisplay id="LBL_COMMENTS" default="Comments"/></td>
		                <td colspan="3">
		                    <html:text property="comments" size="86" maxlength="256"/>
				            <input type="button" value="<mycim2:contentDisplay id="LBS_ADD" default="Add"/>" name="addmember" onclick="javascript:addMember();">
				        </td>
				    </tr>
		        </table>
		   </fieldset>	 
            <br>
		    <table width="100%">
		    <tr>
		        <td>
			        <div align="center">
			        <input type="button" name="Reset" value="<mycim2:contentDisplay id="LBS_RESET" default="Reset"/>" onClick="goToURL('self', doSearchUrl+'&nav=true')">
			        </div>
			    </td>
		    </tr>
	        </table>
        </td>
        </tr>
    </table>
</td>
</tr>
</table>
</html:form>
</body>
</html>
<script type="text/javascript">
var doSearchUrl = '<%=request.getContextPath()%>/lotstependtime.do?edit=1';
var doCarrierSearchUrl = doSearchUrl+'&byCarrierId=1';
window.CN0EN = '<%=(String)session.getAttribute("language")%>';
$(function(){
	setDefault();
	enterSubmitInit('lotId');
	enterSubmitInit4Carrier('carrierId', doCarrierSearchUrl);
    $("input[name='endTime']").focusout(validateEndTime); 
	var errorMsg = $("input[name='errorMsg']").val(); 
	if($.trim(errorMsg).length>0){
		alert(errorMsg);
	}
});
function addMember(){
	if(validateSelect()){
		$("input[type='button']").attr("disabled",true);
		$.ajax({
			cache:false,
	        url:"<%=request.getContextPath()%>/lotstependtime.do?addmember=1&addType=init",
	        data:$('#endtimeForm').serialize(),
	        type: "POST",
	        dataType: "json",
	        error: function(request) {
	            alert("Connection error"); 
	            $("input[type='button']").attr("disabled",false);
	            searchSubmit();
	        },
	        success: function(data) {
	        	if(data.success){
	    			if(data.msg.existQty == 0){
	    				searchSubmit();
	    			}else if(data.msg.existQty>0){
	    				var msg = data.msg.promptMsg;
	    				if(window.CN0EN =="EN"){
    						msg  +=  "\nConfirm to cover it?";
    					}else{
    						msg  +=  "\n確認要覆蓋?";
    					}
	    				if(confirm(msg)){
    						coverAdd(); 
    					}else{
	    				  searchSubmit();
    					}
	    			}
	        	}else{
	        		alert(data.msg);
	        	}
	        	$("input[type='button']").attr("disabled",false);
	        }
	    });
	};	
}
function coverAdd(){
	addMemberAction("cover");
} 
function addMemberAction(addType){
	$("input[type='button']").attr("disabled",true);
	$.ajax({
		cache:false,
        url:"<%=request.getContextPath()%>/lotstependtime.do?addmember=1&addType="+addType,
        data:$('#endtimeForm').serialize(),
        type: "POST",
        dataType: "json",
        error: function(request) {
            alert("Connection error"); 
            $("input[type='button']").attr("disabled",false);
            searchSubmit();
        },
        success: function(data) {
        	if(data.success){
        		searchSubmit();
        	}else{
        		alert(data.msg);
        	}
        	$("input[type='button']").attr("disabled",false);
        }
    });
}


function setDefault(){
	$("input[name='routeId']").val("");
	$("input[name='operationId']").val("");
	$("input[name='routeSeq']").val("");
	$("input[name='operationSeq']").val("");
	/* $("select[name='department']").val("");
	$("input[name='deptExt']").val(""); 
	$("select[name='userId']").val("");*/
}
function doClean(){//清除stepId以外的信息
	$("input[name='routeId']").val("");
	$("input[name='routeSeq']").val("");
	$("input[name='operationSeq']").val("");
}
function validateEndTime(){
	var endTime = $.trim($("input[name='endTime']").val());
	if(endTime.length>0){
		if(!IsNumeric(endTime)){
			if(window.CN0EN == "EN"){
				alert(" The end time can only be a number\n");
	    	}else{
	    		alert("結束時間只能是數字\n");
	    	}
			$("input[name='endTime']").val("");
		}else if(!isHaveTwoDecimalsAtMost(endTime)){
			if(window.CN0EN == "EN"){
				alert("Endtime can only have two decimals at most!\n");
	    	}else{
	    		alert("Endtime最多允許有兩位小數!\n");
	    	}
			if(endTime.indexOf(".")>0){//自動四捨五入,保留兩位有效數字
			  $("input[name='endTime']").val(Math.round(parseFloat(endTime)*100)/100);
			}
		}	
	}
}
function  isHaveTwoDecimalsAtMost(num){//判斷是否是最多隻有兩位小數的數字
	var reg = new RegExp ("^(-?\\d+)(\\.\\d{0,2})?$") ;
	return reg.test(num);
}
function validateSelect(){
	var msg="";
	
	if($.trim($("input[name='operationId']").val()).length<1) {
		if(window.CN0EN == "EN"){
			msg+="The step ID cannot be empty\n";
    	}else{
    		msg+="步驟號不能爲空\n"; 
    	}
	}
	var endTime = $.trim($("input[name='endTime']").val());
	if(endTime.length<1) {
		if(window.CN0EN == "EN"){
			msg+="The end time cannot be empty\n";
    	}else{
    		msg+="結束時間不能爲空\n"; 
    	}
	}else if(!IsNumeric(endTime)){
		if(window.CN0EN == "EN"){
			msg+=" The end time can only be a number\n";
    	}else{
    		msg+="結束時間只能是數字\n"; 
    	}
	}else if(!isHaveTwoDecimalsAtMost(endTime)){
		if(window.CN0EN == "EN"){
			msg+= "Endtime can only have two decimals at most!\n";
    	}else{
    		msg+= "Endtime最多允許有兩位小數!\n";
    	}
	}
	
	if(msg.length>0){
		alert(msg);
		return false;
	}
	return true;
}
function doDelete(url){
	var confirmMsg = (window.CN0EN =="EN") ? "Confirm deletion ?" : "是否確定刪除?";
	if(confirm(confirmMsg)){
		javascript:doSubmit('<%=request.getContextPath()%>/lotstependtime.do?'+url,'1');
	}
}

function verifyAndSubmitImport () {
	var fileName = $("input[name='formFile']").val();
	var suffix = fileName.substring(fileName.length - 4);
	if (suffix != '.xls' ) {
		if(window.CN0EN =="EN"){
			alert("Only file with .xls extension can be imported !");
		}else{
			alert("只能導入xls後綴的文件!");
		}
	} else {
		var theform = document.forms[0];
		theform.action = '<%=request.getContextPath()%>/lotstependtime.do'+'?import=1';
		theform.submit();
	}
}

//-----------function for cascade-----------------
<%-- function getUsers(){
	var s=document.getElementsByName("department")[0];
	var deptId=s.options[s.options.selectedIndex].value;
	var url="<%=request.getContextPath()%>/ajaxflush.do?dept="+deptId;
	ajaxapp1(url);		
}

function getTel(){
	var s1=document.getElementsByName("department")[0];
	var deptId=s1.options[s1.options.selectedIndex].value;
	var s2=document.getElementsByName("userId")[0];
	document.getElementById("userRrn").value=s2.value;
	var userName=s2.options[s2.options.selectedIndex].value;
	var url="<%=request.getContextPath()%>/ajaxflush.do?dept="+deptId+"&user="+userName;
	ajaxapp2(url);		 
}

function ajaxapp2(url){
	var xmlHttp;
	xmlHttp=initAjax();  
	xmlHttp.onreadystatechange=function(){
	      if(xmlHttp.readyState==4){
		      if(xmlHttp.status==200){
	    	  		var t=document.getElementsByName('deptExt')[0];
	    	  		var text=xmlHttp.responseText;
	    	  		t.value=text;
		      }
	      }
	 }
	   //由於ie的緩存,在請求一次服務器後,如果再次請求的url與上一次相同,
	   //ie會直接調用緩存,而不請求服務器。所以要給鏈接加一個時間戳。
	   	url=convertURL(url);
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);

}

function ajaxapp1(url){
	var xmlHttp;
	xmlHttp=initAjax();  
	xmlHttp.onreadystatechange=function(){
	      if(xmlHttp.readyState==4){
		      if(xmlHttp.status==200){
	    	  		var select=document.getElementsByName('userId')[0];
	    	  		var text=xmlHttp.responseXML;
	    	  		var t=document.getElementsByName('deptExt')[0];
	    	  		t.value="";
	    	  		addOptions(select,text);
		      }
	      }
	 }
	   //由於ie的緩存,在請求一次服務器後,如果再次請求的url與上一次相同,
	   //ie會直接調用緩存,而不請求服務器。所以要給鏈接加一個時間戳。
		url=convertURL(url);
	    xmlHttp.open("GET",url,true);
	    xmlHttp.send(null);

}

//初始化xmlhttprequest
function initAjax(){
	var xmlHttp;
	if (window.XMLHttpRequest) {   
        xmlHttp = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    	if(window.CN0EN == "EN"){
			 alert("Your browser is not IE , this feature may not be displayed properly");
		  }else{
			 alert("非IE瀏覽器,該功能可能無法正常顯示!");
		  }  
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xmlHttp;
}

// select表示<select>對象,xml表示XMLDocument對象
function addOptions(select, xml)
{    
    if(select)
    {
        var options = "";
        var cn=xml.childNodes[0];
	        for(var i = 0; i < cn.childNodes.length ; i++)
	        {  
	            if(cn.childNodes[i].nodeName == "list")
	            {
	                var s = "";              
	                s = cn.childNodes[i].text;
	                s=s!=undefined?s:cn.childNodes[i].textContent;
	                var index=s.indexOf("|");
	                var s1=s.substring(0,index);
	                var s2=s.substring(index+1,s.length)      
	                options += "<option value='" + s2 + "'>" ;
	                options += s1;
	                options += "</option>"
	            }
	        }
	            
	        var name = select.name;
	        select.outerHTML = "<select name='" + name + "' onchange='getTel()'>" + options + "</select>"; 
    }
}

//給鏈接加時間戳
function convertURL(url) {   
	  var timstamp = (new Date()).valueOf();   
	  if (url.indexOf("?") >= 0) {   
	    url = url + "&t=" + timstamp;   
	  } else {   
	    url = url + "?t=" + timstamp;   
	  }   
	  return url;   
}  --%>
//-----------end-----------------
</script>

2、翻頁按鈕

 <br>
            
		 <input type="hidden" name="curPage" value="${page.pageNo }" /> 
         <input type="hidden" name="view" value="" /> 
	     <script type="text/javascript">
			function page(val) {
				$('input[name="curPage"]').val(val);
				$('input[name="view"]').val("1");
			}
		 </script>
		<!-- 翻頁工具 -->
		<table width="100%" border="0">
			<tr>
				<div align="right">
					<!-- 首頁 -->
					<logic:equal value="true" name="page" property="firstPage">
						<input type="button" value="  <<  " disabled="disabled" />
					</logic:equal>
					<logic:notEqual value="true" name="page" property="firstPage">
						<input type="submit" value="  <<  " name="search" onClick="javascript:page(1);OpenLoadingDiv();"/">
					</logic:notEqual>
					<!-- 上一頁 -->
					<logic:equal value="true" name="page" property="hasPrePage">
						<input type="submit" value="   <   " name="search" onClick="page(${page.prePage});OpenLoadingDiv();"/">
					</logic:equal>
					<logic:notEqual value="true" name="page" property="hasPrePage">
						<input type="button" value="   <   " disabled="disabled" />
					</logic:notEqual>
					<!-- 下一頁 -->
					<logic:equal value="true" name="page" property="hasNextPage">
						<logic:notEqual value="${page.lastPage}" name="page" property="pageNo">
							<input type="submit" value="   >   " name="search" onClick="page(${page.nextPage});OpenLoadingDiv();"/">
						</logic:notEqual>
					</logic:equal>
					<logic:notEqual value="true" name="page" property="hasNextPage">
						<logic:notEqual value="${page.lastPage}" name="page" property="pageNo">
							<input type="button" value="   >   " disabled="disabled" />
						</logic:notEqual>
					</logic:notEqual>
					<!-- 尾頁 -->
					<logic:greaterThan value="0" name="page" property="totalPages">
						<logic:equal value="false" name="page" property="lastPage">
							<input type="submit" value="  >>  " name="search" onClick="page(${page.totalPages});OpenLoadingDiv();"/">
						</logic:equal>
					</logic:greaterThan>
					<logic:equal value="0" name="page" property="totalPages">
						<input type="button" value="  >>  " disabled="disabled" />
					</logic:equal>
					<logic:equal value="true" name="page" property="lastPage">
						<input type="button" value="  >>  " disabled="disabled" />
					</logic:equal>
				</div>
			</tr>
		</table>

後臺

  private ActionForward view(HttpServletRequest request, HttpServletResponse response, QueryUnitForm theform,
                               ActionMapping mapping) throws Exception {
        Map qryConditions = getQryConditions(request, theform);
        int curPage = WebUtil.getParameterInt("curPage", request);
        Page unitPage = new Page(curPage, PAGESIZE);
        unitPage = getUnitManager().qryUnitTransReason(unitPage, qryConditions);
        handleData(unitPage, request);
        request.setAttribute("page", unitPage);
        return mapping.findForward("view");
    }

logic:iterate

<fieldset id="fld1"><legend><mycim2:contentDisplay  id=""  default="詳細信息"/></legend>
     <table width="100%">
         <tr class=myinnertable> 
			  <td  width="1%">編號</td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="所在批次"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="晶圓片號"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="reason Category"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="responsibility"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="原因代碼"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="原因"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="備註"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="工藝流程"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="工序"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="工步"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="操作人"/></td>
			  <td  width="5%" ><mycim2:contentDisplay  id=""  default="操作時間"/></td>
	      </tr>
	      
	     <logic:iterate id="item" name="page" property="results" indexId="i"  >
		 <tr class=myinnertable2>
			 <td nowrap >${page.startRow+i}</td>
			 <td nowrap ><bean:write name="item" property="lotId"/></td>
			 <td nowrap ><bean:write name="item" property="unitId"/></td>
			 <td nowrap ><bean:write name="item" property="reasonCategory"/></td>
			 <td nowrap ><bean:write name="item" property="responsibility"/></td>
			 <td nowrap ><bean:write name="item" property="reasonCode"/></td>
			 <td nowrap ><bean:write name="item" property="reason"/></td>
			 <td nowrap ><bean:write name="item" property="transComments"/></td>
			 <td nowrap ><bean:write name="item" property="processId"/></td>
			 <td nowrap ><bean:write name="item" property="routeId"/></td>
			 <td nowrap ><bean:write name="item" property="operationId"/></td>
			 <td nowrap ><bean:write name="item" property="transUser"/></td>
			 <td nowrap ><bean:write name="item" property="transTime"/></td>
		 </tr>
		 </logic:iterate>
         </table>            
         </fieldset>

HK移載,翻頁


			         <input type="hidden" name="view" value="" /> 
                     <input type="hidden" name="curPage" value="${page.pageNo }" /> 
				     <script type="text/javascript">
						function page(val) {
							$('input[name="curPage"]').val(val);
							$('input[name="view"]').val("1");
						}
					 </script>
					<!-- 翻頁工具 -->
					<table width="100%" border="0">
						<tr>
							<div align="right">
								<!-- 首頁 -->
								<logic:equal value="true" name="page" property="firstPage">
									<input type="button" value="  <<  " disabled="disabled" />
								</logic:equal>
								<logic:notEqual value="true" name="page" property="firstPage">
									<input type="submit" value="  <<  " name="search" onClick="javascript:page(1);OpenLoadingDiv();"/">
								</logic:notEqual>
								<!-- 上一頁 -->
								<logic:equal value="true" name="page" property="hasPrePage">
									<input type="submit" value="   <   " name="search" onClick="page(${page.prePage});OpenLoadingDiv();"/">
								</logic:equal>
								<logic:notEqual value="true" name="page" property="hasPrePage">
									<input type="button" value="   <   " disabled="disabled" />
								</logic:notEqual>
								<!-- 下一頁 -->
								<logic:equal value="true" name="page" property="hasNextPage">
									<logic:notEqual value="${page.lastPage}" name="page" property="pageNo">
										<input type="submit" value="   >   " name="search" onClick="page(${page.nextPage});OpenLoadingDiv();"/">
									</logic:notEqual>
								</logic:equal>
								<logic:notEqual value="true" name="page" property="hasNextPage">
									<logic:notEqual value="${page.lastPage}" name="page" property="pageNo">
										<input type="button" value="   >   " disabled="disabled" />
									</logic:notEqual>
								</logic:notEqual>
								<!-- 尾頁 -->
								<logic:greaterThan value="0" name="page" property="totalPages">
									<logic:equal value="false" name="page" property="lastPage">
										<input type="submit" value="  >>  " name="search" onClick="page(${page.totalPages});OpenLoadingDiv();"/">
									</logic:equal>
								</logic:greaterThan>
								<logic:equal value="0" name="page" property="totalPages">
									<input type="button" value="  >>  " disabled="disabled" />
								</logic:equal>
								<logic:equal value="true" name="page" property="lastPage">
									<input type="button" value="  >>  " disabled="disabled" />
								</logic:equal>
							</div>
						</tr>
					</table>
					

導出excel

Object[][] datas = { { "區域", "總銷售額(萬元)", "總利潤(萬元)簡單的表格" }, { "江蘇省", 9045, 2256 } };
			HSSFWorkbook wb = new HSSFWorkbook();
			HSSFSheet sheet = wb.createSheet("table"); // 創建table工作薄
			HSSFRow row;
			HSSFCell cell;
			for (int i = 0; i < datas.length; i++) {
				row = sheet.createRow(i);// 創建表格行
				for (int j = 0; j < datas[i].length; j++) {
					cell = row.createCell(j);// 根據表格行創建單元格
					cell.setCellValue(String.valueOf(datas[i][j]));
				}
			}
			wb.write(new FileOutputStream(System.getProperty("user.dir")+"/exportExcel/HSSFWorkbook導出的xls.xls"));
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章