<div class="codetitle"> <span><a style="CURSOR: pointer" data="22999" class="copybut" id="copybut22999" onclick="doCopy('code22999')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code22999"> <br><br><br> <br> <title> new document </title> <br> <meta name="generator" content="editplus"> <br> <meta name="author" content=""> <br> <meta name="keywords" content=""> <br> <meta name="description" content=""> <br> <script language="javascript"> <BR> <!-- <BR> function AutomateExcel() <BR> { <BR> // Start Excel and get Application object. <BR> var oXL = new ActiveXObject("Excel.Application"); <BR> // Get a new workbook. <BR> var oWB = oXL.Workbooks.Add(); <BR> var oSheet = oWB.ActiveSheet; <BR> var table = document.all.data; <BR> var hang = table.rows.length; <BR> var lie = table.rows(0).cells.length; <BR> // Add table headers going cell by cell. <BR> for (i=0;i<hang;i++) <BR> { <BR> for (j=0;j<lie;j++) <BR> { <BR> //oSheet.Cells(i+1,j+1).Font.Bold = True <BR> //oSheet.Cells(i+1,j+1).Font.Size = 50 <BR> //oSheet.Cells(i+1,j+1).Alignment = 2<BR> oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText; <BR> } <BR> } <BR> oXL.Visible = true; <BR> oXL.UserControl = true; <BR> } <BR> //--><BR> </script><br> <br><br> <br> <br> <table border="1" width="100%" id="data"> <br> <tr> <br> <td> 姓名</td> <br> <td colspan="2">年龄</td> <br> <td>出生日期</td> <br> </tr> <br> <tr> <br> <td>6</td> <br> <td>25</td> <br> <td colspan="2">8</td> <br> </tr> <br> <tr> <br> <td height="22">1</td> <br> <td height="22">2</td> <br> <td colspan="2" height="22">4</td> <br> </tr> <br> </table> <br><input type="button" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint"><br> <br><br> </div>