HTML导出Excel

<SCRIPT LANGUAGE="javascript">
<!--
function AutomateExcel() {
var elTable = document.getElementById("table1"); //table1改成你的tableID
var oRangeRef = document.body.createTextRange();
oRangeRef.moveToElementText(elTable);
oRangeRef.execCommand("Copy");
try { var appExcel = new ActiveXObject("Excel.Application"); } catch (e) { alert("无法调用Office对象,请确保您的机器已安装了Office并已将本系统的站点名加入到IE的信任站点列表中!"); return; }
appExcel.Visible = true;
appExcel.Workbooks.Add().Worksheets.Item(1).Paste();
appExcel = null;
}
//-->
</SCRIPT>

调用
<input type="button" name="out_excel" onClick="AutomateExcel();" value="导出到excel" class="notPrint">

内容转自百度知道:https://zhidao.baidu.com/question/1113034720763607499.html

posted @ 2016-11-08 09:31  阿日斯兰  阅读(129)  评论(0)    收藏  举报