<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页上内容导出到word</title>
<script language="javascript">
function OpenWord(){
ExcelSheet = new ActiveXObject('word.Application');
ExcelSheet.Application.Visible = true;
var orgNum=ExcelSheet.Documents.Add('',0,1);
myRange =orgNum.Range(0,1)
sel=parent.document.body.createTextRange();
oTblExport = parent.document.getElementById("Layer1");
if (oTblExport != null) {
sel.moveToElementText(oTblExport);
sel.execCommand('Copy');
parent.document.body.blur();
myRange.Paste();
}
}
</SCRIPT>
</head>
<body>
<div id="Layer1" >Happy New Year ! ! !
<p>3.5版本新特性:</p>
<table border="1" bordercolor="#cccccc" cellpadding="5" width="90%">
<tbody>
<tr>
<td>表格编辑</td>
<td>多语言支持</td>
<td>更漂亮的外观</td>
</tr>
<tr>
<td>回显字体和颜色</td>
<td>表情分页和预览</td>
<td>新API</td>
</tr>
</tbody>
</table>
<img border="0" alt="" src="http://www.cnbeta.com/images/cnlogo.gif" />
<input type=button name='button_export' title='导出到word' οnclick=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>