<HTML>
  <HEAD>
    <title>WEB页面导出为EXCEL文档的方法
    </title>
  </HEAD>
<body>
<BR>
<table id = "PrintA" width="100%" border="1" cellspacing="0" cellpadding="0" bgcolor = "#61FF13">
<TR style="text-align : center;">
 <TD>单元格A</TD>
 <TD>单元格A</TD>
 <TD>单元格A</TD>
 <TD>单元格A</TD>
</TR>
<TR>
 <TD colSpan=4 style="text-align : center;"><font color="BLUE" face="Verdana">单元格合并行A</FONT></TD>
</TR>
</TABLE>
<BR>
<table id = "PrintB" width="100%" border="1" cellspacing="0" cellpadding="0">
<TR style="text-align : center;">
 <TD>单元格B</TD>
 <TD>单元格B</TD>
 <TD>单元格B</TD>
 <TD>单元格B</TD>
</TR>
<TR>
 <TD colSpan=4 style="text-align : center;">单元格合并行B</TD>
</TR>
</TABLE>
<br><br><br>
<img id="divId" src="2.jpg" >
<input type="button" onclick="javascript:AllAreaWord();" value="导出页面指定区域内容到Word" ID=Button1>
<input type="button" onclick="javascript:importToExcel();" value="导出图片到Word" ID=Button4>
<SCRIPT LANGUAGE="javascript">
 //指定页面区域内容导入Excel function importToExcel()
{
  var oWD = new ActiveXObject("Word.Application");
  var oDC = oWD.Documents.Add("",0,1);
  var oRange =oDC.Range(0,1);
  var div = document.getElementById('divId');
 div.contentEditable = 'true';
 var controlRange;
 if (document.body.createControlRange) 
 {
 controlRange = document.body.createControlRange();
 controlRange.addElement(div);
 controlRange.execCommand('Copy');
  oRange.Paste();
  oWD.Application.Visible = true;}
} function AllAreaWord()
 {
  var oWD = new ActiveXObject("Word.Application");
  var oDC = oWD.Documents.Add("",0,1);
  var oRange =oDC.Range(0,1);
  var sel = document.body.createTextRange();
  sel.moveToElementText(PrintA);
  sel.select();
  sel.execCommand("Copy");
  oRange.Paste();
  oWD.Application.Visible = true;
  //window.close();
 }
</SCRIPT>
</body></html>