标签:des style blog http color os
IE设置:
工具-> Internet选项-> 安全->自定义级别-> 对没有标记安全级别的ActiveX控件进行初始化
设为启用!
//指定区域导出到Word function html2word(Area) { var oWD = new ActiveXObject("Word.Application"); var oDC = oWD.Documents.Add("", 0, 1); var oRange = oDC.Range(0, 1); var sel = document.body.createTextRange(); sel.moveToElementText(document.getElementById(Area)); sel.select(); sel.execCommand("Copy"); oRange.Paste(); oWD.Application.Visible = true; }
Area:要导出的html元素ID。
//指定区域导出到Excel function html2Excel(Area) { try { var oRangeRef = document.body.createTextRange(); oRangeRef.moveToElementText(document.getElementById(Area)); //oRangeRef.select(); oRangeRef.execCommand("Copy"); var oXL = new ActiveXObject("Excel.Application"); var oWB = oXL.Workbooks.Add; var oSheet = oWB.ActiveSheet; oSheet.Paste(); oXL.Visible = true; oSheet = null; oWB = null; oXL = null; } catch (e) { alert(e.description) } }
Area:要导出的html元素ID。
转载:http://www.cnblogs.com/sobne/articles/2103999.html
网页内容导出word/excel的js代码,布布扣,bubuko.com
标签:des style blog http color os
原文地址:http://www.cnblogs.com/smile-wei/p/3860885.html