zoukankan      html  css  js  c++  java
  • [分享]客户端操作Excel文档

    代码:

    <input type="hidden" name="out_word" onclick="vbscript:buildDoc" value="导出到word" class="notPrint">
    <input type="hidden" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint">

    <title>浏览器表格导出到Excel代码</title>
    <input type="button" name="out_word" onclick="vbscript:buildDoc" value="导出到word" class="notPrint">
    <input type="button" name="out_word1" onclick="javascript:AutomateExcel() " value="导出到excel" class="notPrint">


    <table id="data" width="200" border="1">
      <tr>
        <td>11</td>
        <td>11</td>
      </tr>
      <tr>
        <td>22</td>
        <td>22</td>
      </tr>
      <tr>
        <td>33</td>
        <td>33</td>
      </tr>
      <tr>
        <td>44 </td>
        <td>44</td>
      </tr>
    </table>


    <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).Value = table.rows(i).cells(j).innerText;
    }

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

  • 相关阅读:
    mysql优化
    查询优化
    MySql服务器逻辑架构
    存储过程和存储函数区别
    mysql表设计原则
    mysql事务
    操作系统内存管理
    mysql索引介绍
    InnoDB与Myisam的区别
    【SVN】关于钩子的一些使用
  • 原文地址:https://www.cnblogs.com/goody9807/p/221679.html
Copyright © 2011-2022 走看看