• js导出成excel


        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
        <!– saved from url=(0047)http://localhost:8080/ExtDemo/tabletoexcel.html –>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>无标题文档</title>
        <script type="text/javascript">
        <!-- download
        function saveCode(obj) {
                  var winname = window.open('', '_blank', 'top=10000');
                  var strHTML = document.all.tableExcel.innerHTML;
                  winname.document.open('text/html', 'replace');
                  winname.document.writeln(strHTML);
                  winname.document.execCommand('saveas','','excel.xls');
                  winname.close();
        }
        -->
        </script>
        </head>
        <div id="tableExcel">
        <table id="test" width="100%" border="1" cellspacing="0" cellpadding="0">
              <tr>
                  <td colspan="5" align="center">WEB页面导出为EXCEL文档的方法</td>
              </tr>
              <tr>
                  <td>列标题1</td>
                  <td>列标题2</td>
                  <td>列标题3</td>
                  <td>列标题4</td>
                  <td>列标题5</td>
              </tr>
              <tr>
                  <td>aaa</td>
                  <td>bbb</td>
                  <td>ccc</td>
                  <td>ddd</td>
                  <td>eee</td>
              </tr>
              <tr>
                  <td>AAA</td>
                  <td>BBB</td>
                  <td>CCC</td>
                  <td>DDD</td>
                  <td>EEE</td>
              </tr>
              <tr>
                  <td>FFF</td>
                  <td>GGG</td>
                  <td>HHH</td>
                  <td>III</td>
                  <td>JJJ</td>
              </tr>
              <tr>
                <td>aaa</td>
                <td>bbb</td>
                <td>ccc</td>
                <td>ddd</td>
                <td>eee</td>
              </tr>
              <tr>
                <td>AAA</td>
                <td>BBB</td>
                <td>CCC</td>
                <td>DDD</td>
                <td>EEE</td>
              </tr>
              <tr>
                <td colspan="5">FFFGGGHHHIIIJJJ</td>
              </tr>
             
              <tr>
                <td>aaa</td>
                <td>bbb</td>
                <td>ccc</td>
                <td>ddd</td>
                <td>eee</td>
              </tr>
              <tr>
                <td>AAA</td>
                <td>BBB</td>
                <td rowspan="4">CCCHHHcccccc</td>
                <td>DDD</td>
                <td>EEE</td>
              </tr>
              <tr>
                <td>FFF</td>
                <td>GGG</td>
                <td>III</td>
                <td>JJJ</td>
              </tr>
             
              <tr>
                <td>aaa</td>
                <td>bbb</td>
                <td>ddd</td>
                <td>eee</td>
              </tr>
              <tr>
                <td>aaa</td>
                <td>bbb</td>
                <td>ddd</td>
                <td>eee</td>
              </tr>
              <tr>
                <td>AAA</td>
                <td>BBB</td>
                <td>CCC</td>
                <td>DDD</td>
                <td>EEE</td>
              </tr>
              <tr>
                <td>FFF</td>
                <td>GGG</td>
                <td>HHH</td>
                <td>III</td>
                <td>JJJ</td>
              </tr>
        </table>
        </div>
        <body>
        <input type="button" value="另存为 Excel" onclick="saveCode(tableExcel)">
        </body>
        </html>
    
    


  • 相关阅读:
    JAVA WEB开发环境与搭建
    计科院静态网页
    Python操作MySQL数据库的三种方法
    Appium环境搭建
    webstorm 默认代码格式化更改,webstorm设置prettier规则
    appium自动化环境搭建
    从事算法设计应当熟悉的资源
    redhat6如何配置本地yum源
    Windows命令查看活动连接及根据PID查看运行程序的路径、程序名等
    Tomcat与JavaWeb技术详解
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3327602.html
Copyright © 2020-2023  润新知