js 到处到 excel 很实用的代码 - 飘凌大杂烩
飘凌大杂烩电脑网络手机数码编程技术js 到处到 excel 很实用的代码
    
 
js 到处到 excel 很实用的代码
发起人:piaoling  回复数:0  浏览数:5771  最后更新:2009/12/25 10:21:06 by piaoling

选择查看 搜索更多相关主题  帖子排序:
2009/12/25 10:21:06
piaoling






角  色:管理员
等  级:旅长
发 帖 数:672
经 验 值:2001
注册时间:2008/12/7
js 到处到 excel 很实用的代码
<script language="javascript">
function tableToExcel() { //导入Excel
window.clipboardData.setData("Text",document.all('theObjTable').outerHTML);
try
{
var ExApp = new ActiveXObject("Excel.Application")
var ExWBk = ExApp.workbooks.add()
var ExWSh = ExWBk.worksheets(1)
ExApp.DisplayAlerts = false
ExApp.visible = true
ExWSh.Columns("A:A").ColumnWidth = 7 //根据具体情况设置行宽
ExWSh.Columns("B:B").ColumnWidth = 19
ExWSh.Columns("C:C").ColumnWidth = 40
ExWSh.Columns("D:D").ColumnWidth = 20
ExWSh.Columns("E:E").ColumnWidth = 23
ExWSh.Columns("F:F").ColumnWidth = 7
ExWSh.Rows("1:1").RowHeight = 79.5 //根据具体情设置行高
ExWSh.Rows("2:2").RowHeight = 84
ExWSh.Rows("3:3").RowHeight = 36.75
ExWSh.Rows("4:4").RowHeight = 75
ExWSh.Rows("5:5").RowHeight = 30
ExWSh.Rows("6:6").RowHeight = 30
ExWSh.Rows("7:7").RowHeight = 30
ExWSh.PageSetup.Orientation = 2 //设置页面方向,1为纵向,2为横向 }
catch(e){
alert("您的电脑没有安装Microsoft Excel软件!")
return false
}
ExWBk.worksheets(1).Paste;
}
</script>
<input type="button" name="Submit" value="导出到Excel" onclick="javascript:tableToExcel()"> //导出按钮
<table width="855" border="0" align="center" cellpadding="0" cellspacing="0" id="theObjTable"> //具体要到到Excel的表格对象
返回页首↑


津ICP备09000164号

联系我们 - piaoling Corporation - 论坛存档 - 返回顶端
Powered by BBSXP 2007 ACCESS © 1998-2025
Server Time 2025/1/14 1:19:03
Processed in 0.02 second(s)
飘凌大杂烩