Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
How to export a <title>web page to an Excel document </title>
<body>
<table id= "Tableexcel" width= "100%" border= "1" cellspacing= "0" cellpadding= "0" >
<tr>
<TD colspan= "5" align= "Center" >
How a Web page is exported as an Excel document
</td>
</tr>
<tr>
<td>
Column Heading 1
</td>
<td>
Column Heading 2
</td>
<td>
Column Heading 3
</td>
<td>
Column Heading 4
</td>
<td>
Column Heading 5
</td>
</tr>
<tr>
<td>
Aaa
</td>
<td>
</td>
<td>
Ccc
</td>
<td>
Ddd
</td>
<td>
Eee
</td>
</tr>
<tr>
<td>
Aaa
</td>
<td>
</td>
<td>
Ccc
</td>
<td>
Ddd
</td>
<td>
EEE
</td>
</tr>
<tr>
<td>
FFF
</td>
<td>
GGG
</td>
<td>
HHH
</td>
<td>
Iii
</td>
<td>
Jjj
</td>
</tr>
</table>
<input type= "button" onclick= javascript:method1 (' Tableexcel '); "value=" first method import to Excel >
<script language= "JavaScript" >
function Method1 (tableid) {//Full table Copy to Excel
var curtbl = document.getElementById (TableID);
var oXL = new ActiveXObject ("Excel.Application"); Create an Ax object Excel
var owb = OXL.Workbooks.Add (); Get Workbook Object
var osheet = Owb.activesheet; Activate current sheet
var sel = Document.body.createTextRange ();
Sel.movetoelementtext (CURTBL); Move the contents of the table to TextRange
Sel.select (); Full selection of TextRange contents
Sel.execcommand ("Copy"); Copy content in TextRange
Osheet.paste (); Paste into active Excel
oXL.Visible = true; Set Excel Visible Properties
}
</script>
</body>