jspÖÐtableµ¼³ÉexclÎļþ
ÏîĿҪÇ󽫺ǫ́Êý¾Ý½øÐÐÏÔʾ£¨ÏÔʾҪÇ󲿷ÖÄÚÈݽøÐÐÁÐÏîºÏ²¢£©£¬ÔÚ¶ÔÏÔʾµÄÊý¾Ý½øÐе¼³ö³Éexcel
ʵÏÖ¹ý³Ì
1¡¢²éѯºÍµ¼³öµÄjspÒ³Ãæ ¹Ø¼ü´úÂë
<script language=javascript>
function exportExcel(){
/****ʵÏÖ·½·¨Ò»
<%-- var curTbl = document.getElementById("techQueryTab"); --%>
<%-- var oXL = new ActiveXObject("Excel.Application"); --%>
<%-- //´´½¨AX¶ÔÏóexcel --%>
<%-- var oWB = oXL.Workbooks.Add(); --%>
<%-- //»ñÈ¡workbook¶ÔÏó --%>
<%-- var oSheet = oWB.ActiveSheet; --%>
<%-- //¼¤»îµ±Ç°sheet --%>
<%-- var sel = document.body.createTextRange(); --%>
<%-- sel.moveToElementText(curTbl); --%>
<%-- //°Ñ±í¸ñÖеÄÄÚÈÝÒÆµ½TextRangeÖÐ --%>
<%-- sel.select(); --%>
<%-- //ȫѡTextRangeÖÐÄÚÈÝ --%>
<%-- sel.execCommand("Copy"); --%>
<%-- //¸´ÖÆTextRangeÖÐÄÚÈÝ --%>
<%-- oSheet.Paste(); --%>
<%-- //Õ³Ìùµ½»î¶¯µÄEXCELÖÐ --%>
<%-- oXL.Visible = true; --%>
<%-- //ÉèÖÃexcel¿É¼ûÊôÐÔ --%>
***ʵÏÖ·½·¨Ò»*/
//***ʵÏÖ·½·¨¶þ ͨ¹ýform½øÐÐÌá½»ÖÁhtml2excel.jsp
var myform=document.createElement('form');
myform.action='common/html2excel.jsp';
myform.method='post';
myform.target='_blank';
var html=document.createElement('<input type="hidden" name="html">');
html.value=document.getElementById('table-container').innerHTML;
myform.appendChild(html);
document.appendChild(myform);
myform.submit();
}
//ʵÏÖ·½·¨¶þ½áβ
</script>
¡£¡£¡£
//¹¹Ôìtable²¿·Ö
<div id='table-container'>
<table id="techQueryTab" width="100%" borde
Ïà¹ØÎĵµ£º
ÂÒÂëÕæÊǸöÁîÈËÌÖÑáµÄÎÊÌâ~
¸Õ²ÅÖÕÓÚ°ÑMySQLÓëJSP½»»¥µÄÂÒÂëÎÊÌâ½â¾öÁË¡£
°ì·¨ÈçÏ£º
1.ÔÚurl´¦¼ÓÉϾä×Ó "&useUnicode=true&characterEncoding=GBK" £»
2.ÎÒÓÃNavicat Lite¿ÉÊÓ»¯¹¤¾ß´´½¨MySQLÊý¾Ý¿âʱ£¬¿ÉÑ¡¶¨Êý¾Ý¿â±àÂ룬ҲÊÇ GBK £»
3.Ò³ÃæµÄ±àÂë¿ÉÒÔÑ¡GBKÒÔÍâµÄ±àÂ뷽ʽ£¬ÈçUTF-8¡£Èô²Ù×÷Ò³ÃæµÄ±àÂëÊÇUTF- ......
Ò» ¡¢ ÓÃstruts2±êÇ©µÄ<s:selectÀ´ÏÔʾ
<s:select cssStyle="width: 84%" list="#application.officeList" headerKey="" headerValue="--ÇëÑ¡Ôñ--" listKey="#this.value" listValue="#this.key+'.'+#this.value" name="entity.officeName" value="entity.officeName"/>
ÆäÖÐ
1¡¢listÊǽÓÊÕjavaÀà»òÕßÔÚÆô¶¯Ê± ......
<script language="javascript">
function window.onunload(){
//ËùÓд°¿Ú¹Ø±Õ
if((window.screenLeft>=10000 && window.screenTop>=10000) || event.altKey)
{ //µã»÷ÓÒÉϽǵĴ°¿Ú¹Ø±Õ
alert("aaaaaaaaaaaaaaaaaa");
}
}
</s ......
JSPÖеÄÌø×ª£º
(1). forward()·½·¨
ʹÓõ½javax.servlet.RequestDispatcherÀà
RequestDispatcher rd = getServletContext().getRequestDispatcher("url");
rd.forward(requestVar,requestVar); //´«µÝservletµÄÈë¿Ú²ÎÊý
/*forwardº ......
Àý×Ó˵Ã÷£ºÕâÀý×ÓÊÇѧÉú»ù±¾ÐÅÏ¢µÄÊäÈëÒÔ¼°Êä³öÏÔʾ;ÓÐÁ½¸öÒ³Ãæ£ºinfo.jspºÍshowInfo.jsp£¬Ç°ÕßÊǹ˿ÍÊäÈëµÄÐÅÏ¢Ò³Ãæ£¬¶øºóÕßÊÇ´¦ÀíÐÅÏ¢µÄÒ³Ãæ¡£
info.jsp
<%@page contentType="text/html;charset=gb2312"%>
<HTML>
<HEAD>
<TITLE>ÊäÈëѧ ......