1.word
var word = new ActiveXObject("Word.Application"); var curTbl = document.getElementById("tabid"); var doc = word.Documents.Add("",0,1);//不打开模版直接加入内容 var Range=doc.Range(0,1); var sel = document.body.createTextRange(); sel.moveToElementText(curTbl);// sel.select(); sel.execCommand("Copy"); Range.Paste(); word.Application.Visible = true; 2.excel var oXL = new ActiveXObject("Excel.Application"); var oWB = oXL.Workbooks.Add(); var oSheet = oWB.ActiveSheet; var sel=document.body.createTextRange(); sel.moveToElementText(RS); sel.select(); sel.execCommand("Copy"); oSheet.Paste(); oXL.Visible = true; idTmr = window.setInterval("Cleanup();",1); alert("Successful Output To Excel!"); //clear taskmgr function Cleanup(){ window.clearInterval(idTmr); CollectGarbage();//用于浏览器清除垃圾,释放缓存 } |
jsp页面导出成word,excel
最新推荐文章于 2024-11-11 00:03:55 发布