复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
  <title> new document </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
  <SCRIPT LANGUAGE="javascript"> 
  <!-- 
  function AutomateExcel() 
  { 
  // Start Excel and get Application object. 
  var oXL = new ActiveXObject("Excel.Application"); 
  // Get a new workbook. 
  var oWB = oXL.Workbooks.Add(); 
  var oSheet = oWB.ActiveSheet; 
  var table = document.all.data; 
  var hang = table.rows.length;
  var lie = table.rows(0).cells.length; 
  // 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).value = table.rows(i).cells(j).innerText; 
  } 
  } 
  oXL.Visible = true; 
  oXL.UserControl = true; 
  } 
  //-->
  </SCRIPT>
 </head>

 
 <body>
   <table border="1" width="100%" id="data">
  <tr>
   <td>&nbsp;姓名</td>
   <td colspan="2">年龄</td>
   <td>出生日期</td>
  </tr>
  <tr>
   <td>6</td>
   <td>25</td>
   <td colspan="2">8</td>
  </tr>
  <tr>
   <td height="22">1</td>
   <td height="22">2</td>
   <td colspan="2" height="22">4</td>
  </tr>
  </table>
<input type="button" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint">
 </body>
</html>
标签:
JS,表单,EXCEL

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com

评论“JS将表单导出成EXCEL的实例代码”

暂无“JS将表单导出成EXCEL的实例代码”评论...