<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
 String.prototype.trim = function() { 
 return this.replace(/(^\s*)|(\s*$)/g, ""); 
 }
 function expExcel()
 {
 // start excel and get application object. 
 try
 {
 var oxl = new ActiveXObject("Excel.Application");    
 }catch (exception)
 {
 window.alert("导出失败!");
 return false;
 }
 // get a new workbook.
 var owb = oxl.workbooks.add();
 var osheet = owb.activesheet;
 var table = document.all.table1;
 var hang = table.rows.length; 
 var lie = table.rows(0).cells.length; 
 var i=0;
 var j=0;
 
 // add table headers going cell by cell.
 for (i=0;i<hang;i++) 
 {
 for (j=0;j<lie;j++)
 {
 //osheet.cells(i+1,j+1).font.bold = true
 //osheet.cells(i+1,j+1).font.size = 50
 //osheet.cells(i+1,j+1).alignment = 2
 osheet.cells(i+1,j+1).NumberFormatLocal = "@"
 
 var gettd=table.rows(i).getElementsByTagName("td");
 var getstring=gettd.item(j).innerHTML;
 var v_pos;
 getstring=getstring.trim();
 if (getstring.substr(getstring.length - 3,4)=="/A>")
 {
 v_pos=getstring.indexOf(">");
 getstring=getstring.substr(v_pos + 1,getstring.length - v_pos - 5)
 }
 osheet.cells(i+1,j+1).value = " "+getstring;
 }
 }
 oxl.visible = true; 
 oxl.usercontrol = true;
 }
//-->
</SCRIPT>
</head>
<body>
 <table id ="table1">
 <tr>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 </tr>
 <tr>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 </tr>
 <tr>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 <td>fhasdif
 </td>
 </tr>
 </table>
 <input type="button" value="Exp Excle" οnclick="expExcel();">
</body>
</html>