Ame & quot; code & quot; class & quot; html & quot; & gt; foreground call (the first parameter is the table id): & lt; inputvalue & quot; export & quot; type & quot; button & quot;/& gt; functiontoExcel (inTblId, inWindow) {if ($. B
Ame = "code" class = "html"> foreground call (the first parameter is the table id ):Function toExcel (inTblId, inWindow) {if ($. browser. msie) {// if it is an IE browser try {var allStr = ""; var curStr = ""; if (inTblId! = Null & inTblId! = "" & InTblId! = "Null") {curStr = getTblData (inTblId, inWindow);} if (curStr! = Null) {allStr + = curStr;} else {alert ("the table you want to export does not exist! "); Return;} var fileName = getExcelFileName (); doFileExport (fileName, allStr);} catch (e) {alert (" Export exception: "+ e. name + "->" + e. description + "! ") ;}} Else {window. open ('data: application/vnd. ms-excel, '+ encodeuricomponent({('div?id==divgvdata='{.html (); e. preventDefault () ;}} function getTblData (inTbl, inWindow) {var rows = 0; var tblDocument = document; if (!! InWindow & inWindow! = "") {If (! Document. all (inWindow) {return null;} else {tblDocument = eval(inWindow).doc ument ;}} var curTbl = tblDocument. getElementById (inTbl); if (curTbl. rows. length> 65000) {alert ('the number of source rows cannot exceed 65000 rows'); return false;} if (curTbl. rows. length <= 1) {alert ('data source has no date'); return false;} var outStr = ""; if (curTbl! = Null) {for (var j = 0; j <curTbl. rows. length; j ++) {for (var I = 0; I <curTbl. rows [j]. cells. length; I ++) {if (I = 0 & rows> 0) {outStr + = "\ t"; rows-= 1 ;}var tc = curTbl. rows [j]. cells [I]; if (j> 0 & tc. hasChildNodes () & tc. firstChild. nodeName. toLowerCase () = "input") {if (tc. firstChild. type. toLowerCase () = "checkbox") {if (tc. firstChild. checked = true) {outStr + = "yes" + "\ t ";} Else {outStr + = "no" + "\ t" ;}}} else {outStr + = "" + curTbl. rows [j]. cells [I]. innerText + "\ t";} if (curTbl. rows [j]. cells [I]. colSpan> 1) {for (var k = 0; k <curTbl. rows [j]. cells [I]. colSpan-1; k ++) {outStr + = "\ t" ;}} if (I = 0) {if (rows = 0 & curTbl. rows [j]. cells [I]. rowSpan> 1) {rows = curTbl. rows [j]. cells [I]. rowSpan-1 ;}}outstr + = "\ r \ n" ;}} else {outStr = null; alert (InTbl + "does not exist! ");} Return outStr;} function getExcelFileName () {var d = new Date (); var curYear = d. getYear (); var curMonth = "" + (d. getMonth () + 1); var curDate = "" + d. getDate (); var curHour = "" + d. getHours (); var curMinute = "" + d. getMinutes (); var curSecond = "" + d. getSeconds (); if (curMonth. length = 1) {curMonth = "0" + curMonth;} if (curDate. length = 1) {curDate = "0" + curDate;} if (curHour. Length = 1) {curHour = "0" + curHour;} if (curMinute. length = 1) {curMinute = "0" + curMinute;} if (curSecond. length = 1) {curSecond = "0" + curSecond;} var fileName = "device status" + curYear + curMonth + curDate + curHour + curMinute + curSecond + ". xls "; return fileName;} function doFileExport (inName, inStr) {var xlsWin = null; if (!! Document. all ("glbHideFrm") {xlsWin = glbHideFrm;} else {var width = 1; var height = 1; var openPara = "left =" + (window. screen. width/2 + width/2) + ", top =" + (window. screen. height + height/2) + ", scrollbars = no, width =" + width + ", height =" + height; xlsWin = window. open ("", "_ blank", openPara);} xlsWin.doc ument. write (inStr); xlsWin.doc ument. close (); xlsWin.document.exe cCommand ('saveas', true, inName); xlsWin. close ();}