表格导出EXCEL

<TABLE   id="outtable"   name="outtable" border=1>  
  <TR>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  </TR>  
  <TR>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  </TR><TR>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  </TR><TR>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  </TR><TR>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  <TD>asdf</TD>  
  </TR>  
  </TABLE>  
<input   type="button"   name="out_excel"   onclick="AutomateExcel();"

 

<SCRIPT   LANGUAGE="javascript">
  function   AutomateExcel()
  {
  var   oXL   =   new   ActiveXObject("Excel.Application");
  var   oWB   =   oXL.Workbooks.Add();
  var   oSheet   =   oWB.ActiveSheet;
  var   hang   =   outtable.rows.length;

  var   lie   =   outtable.rows(0).cells.length;

  for   (i=0;i<hang;i++)
  {
  for   (j=0;j<lie;j++)
  {
  oSheet.Cells(i+1,j+1).value   =   outtable.rows(i).cells(j).innerText;
  }

  }
  oXL.Visible   =   true;
  oXL.UserControl   =   true;
  }
  </SCRIPT>

你可能感兴趣的:(导出Excel)