포그라운드 호출(첫 번째 매개변수는 테이블의 ID): <input value="export" type="button" /> <br>function toExcel(inTblId, inWindow) { <br>if ($ .browser.msie ) { //IE 브라우저인 경우 <br>try { <br>var allStr = "" <br>var curStr = "" <br>if (inTblId != null && inTblId != " " && inTblId ! = "null") { <br>curStr = getTblData(inTblId, inWindow); <br>} <br>if (curStr != null) { <br>allStr = curStr; <br>} <br>else { <br>alert("내보내려는 테이블이 존재하지 않습니다!"); <br>return; <br>} <br>var fileName = getExcelFileName() <br>doFileExport(fileName, allStr) ; <br>} <br>catch (e) { <br>alert("Export 예외:" e.name "->" e.description "!"); else { <br> window.open('data:application/vnd.ms-excel,' encodeURIComponent($('div[id$=divGvData]').html())) <br>e.preventDefault() ; <br>} <br>} <br>function getTblData(inTbl, inWindow) { <br>varrows = 0; <br>var tblDocument = document; <br>if (!!inWindow && inWindow != "" ) { <br> if (!document.all(inWindow)) { <br>return null; <br>} <br>else { <br>tblDocument = eval(inWindow).document; } <br>var curTbl = tblDocument.getElementById(inTbl); <br>if (curTbl.rows.length > 65000) { <br>alert('소스 행 수는 65000행을 초과할 수 없습니다.'); 🎜>return false; <br>} <br>if (curTbl.rows.length <= 1) { <BR>alert('데이터 소스에 데이터가 없습니다.') <BR>return false; 🎜>var outStr = ""; <BR>if (curTbl != null) { <BR>for (var j = 0; j < curTbl.rows.length; j ) { <BR>for (var i = 0 ; i < curTbl.rows[j] .cells.length; i ) { <BR>if (i == 0 && 행 > 0) { <BR>outStr = " t" -= 1 ; <BR>} <BR>var tc = curTbl.rows[j].cells[i] <BR>if (j > 0 && tc.hasChildNodes() && tc.firstChild.nodeName.toLowerCase() == "input") { <BR>if ( tc.firstChild.type.toLowerCase() == "checkbox") { <BR>if (tc.firstChild.checked == true) { <BR>outStr = "예" " t"; <BR>} <BR> else { <BR>outStr = "아니요" "t"; <BR>} <BR>} <BR>} <BR>else { <BR><BR>outStr = " " curTbl.rows[j].cells[ i].innerText "t"; <BR>} <BR>if (curTbl.rows[j].cells[i].colSpan > 1) { <br>for ( var k = 0; curTbl.rows[j].cells[i].colSpan - 1; == 0) { <br>if ( 행 == 0 && curTbl.rows[j].cells[i].rowSpan > 1) { <br>rows = curTbl.rows[j].cells[i]. rowSpan - 1 <br>} <br>} <br>outStr = "rn"; <br>} <br>} <br>else { <br>outStr = null; inTbl "존재하지 않습니다!"); <br>} <br>return outStr; <br>} <br>function getExcelFileName() { <br>var d = new Date() <br>var curYear = d. getYear(); <br>var curMonth = " " (d.getMonth() 1) <br>var curDate = "" d.getDate() <br>var curHour = "" d.getHours(); 🎜>var curMinute = "" d.getMinutes( ); <br>var curSecond = "" d.getSeconds(); <br>if (curMonth.length == 1) { <br>curMonth = "0" curMonth; <br>} <br>if (curDate.length == 1) { <br>curDate = "0" curDate <br>} <br>if (curHour.length == 1) { <br>curHour = " 0" curHour; <br>} <br> if (curMinute.length == 1) { <br>curMinute = "0" curMinute; <br>} <br>if (curSecond.length == 1) { <br>curSecond = "0" curSecond; <br> } <br>var fileName = "장치 상태" curYear curMonth curDate curHour curMinute curSecond ".xls"; <br>return fileName(inName) , inStr) { <br>var xlsWin = null ; <br>if (!!document.all("glbHideFrm")) { <br>xlsWin = glbHideFrm <br>} <br>else { <br>var width = 1; <br>var 높이 = 1; <br>var openPara = "left=" (window.screen.width / 2 너비 / 2) <br> ",top=" (window.screen.height 높이 / 2 ) <br> ",scrollbars=no,width =" width ",height=" height; <br>xlsWin = window.open("", "_blank", openPara) <br>} <br>xlsWin.document .write(inStr); <br>xlsWin.document.execCommand('Saveas', true, inName) <br>xlsWin.close(); /pre> <br><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><br><br> <br><br>
로그인 후 복사