请教关于table中的内容导出到word里的问题
大家好,我想实现一个功能,将table里面的内容导出到word里面,可是从网上找了例子运行却没有反映,网上的例子强调:要将active安全设置打开,是指在IE里面对active进行设置吗?
以下是代码:
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> word </title>
</head>
<body>
<div id= "Layer1 "> Happy New Year ! ! ! <input type= "button " name= "button_export " title= "导出到word " onclick= "OpenWord() " value= "下载到word "> </div>
</div>
<p> this is a test! </p>
<table align= "center " width= "300 " border= "1 " bordercolor= "#2baeff " cellpadding= "0 " cellspacing= "0 "
bgcolor= "lightblue ">
<Tr>
<Td> 1 </Td>
<Td> 2 </Td>
<Td> 3 </Td>
</Tr>
<Tr>
<Td> 4 </Td>
<Td> 5 </Td>
<Td> 6 </Td>
</Tr>
<Tr>
<Td> 7 </Td>
<Td> 8 </Td>
<Td> 9 </Td>
</Tr>
</table>
</body>
</html>
<script language= "javascript ">
function OpenWord(){
Layer1.style.border=0
ExcelSheet = new ActiveXObject( "Word.Application ");
ExcelSheet.Application.Visible = true;
var mydoc=ExcelSheet.Documents.Add( " ",0,1);
myRange =mydoc.Range(0,1)
var sel=Layer1.document.body.createTextRange()
sel.select()
Layer1.document.execCommand( "Copy ")
sel.moveEnd( "character ")
myRange.Paste();
location.reload()
ExcelSheet.ActiveWindow.ActivePane.View.Type=9
}
</script>
请大家帮我看看.谢谢了!
------解决方案--------------------http://www.matrix.org.cn/resource/article/2006-01-10/Javascript_44146.html
http://www.tomore.com/4/3651.html