六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 36|回复: 0

把整个网页的表格导出到word

[复制链接]

升级  72.33%

131

主题

131

主题

131

主题

举人

Rank: 3Rank: 3

积分
417
 楼主| 发表于 2013-2-7 17:34:45 | 显示全部楼层 |阅读模式
 
 
 
<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>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页上内容导出到word</title>
</head>
<body>
<div id="Layer1" >
<input type=button name='button_export' title='导出到word' onclick=OpenWord() value=下载到word></div>
</div>
<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>
<Tr>
<Td>7</td>
<Td>8</td>
<Td>9</td>
</tr> <Tr>
<Td>7</td>
<Td>8</td>
<Td>9</td>
</tr>
<Tr>
<Td>7</td>
<Td>8</td>
<Td>9</td>
</tr>
<Tr>
<Td>7</td>
<Td>8</td>
<Td>9</td>
</tr>
</table>
<div id="d2">
<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>
  <Tr>
    <Td>7</td>
    <Td>8</td>
    <Td>9</td>
  </tr>
  <Tr>
    <Td>7</td>
    <Td>8</td>
    <Td>9</td>
  </tr>
  <Tr>
    <Td>7</td>
    <Td>8</td>
    <Td>9</td>
  </tr>
  <Tr>
    <Td>7</td>
    <Td>8</td>
    <Td>9</td>
  </tr>
</table></div>
</body>
</html>  
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表