jquery.table2excel,將HTML的table標簽數據導出成excel


<!DOCTYPE>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>TABLE轉換EXCEL</title>
        <script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js" ></script>
        <script src="js/jquery.table2excel.js"></script>
        <style type="text/css">
            .btn{
                margin:20px;
            }
        </style>
    </head>
    <body>
        <center>
            <input class="btn" type="button"  value="點擊導出">
            <div class="table2excel">
                <table id = 'testTable' border="1">
                    <tr>
                        <th>標題一</th>
                        <th>標題二</th>
                        <th>標題三</th>
                    </tr>
                    <tr  class="noExl">
                      <td>100 (不導出)</td>
                      <td>200 (不導出)</td>
                      <td>300 (不導出)</td>
                    </tr>
                    <tr>
                      <td>400</td>
                      <td>500</td>
                      <td>600</td>
                    </tr>
                    <tr>
                      <td><a href="http://www.baidu.com">baidu.com</a></td>
                      <td><input tyle="text" value="input 數據"></td>
                      <td><img src="http://yuyuan:8080/zzz/img/test.jpg" alt="image"></td>
                    </tr>
                </table>
            </div>
        </center>
        <script type="text/javascript">
            $(function() {
                $(".btn").click(function(){
                    $(".table2excel").table2excel({
                        // 不被導出的表格行的CSS class類
                        exclude: ".noExl",
                        // 導出的Excel文檔的名稱
                        name: "Excel Document Name",
                        // Excel文件的名稱
                        filename: "test",
                        //文件后綴名
                        fileext: ".xls",
                        //是否排除導出圖片
                        exclude_img: false,
                        //是否排除導出超鏈接
                        exclude_links: false,
                        //是否排除導出輸入框中的內容
                        exclude_inputs: false
                    });
                }); 
            });
        </script>
    </body>
</html>

原文鏈接 : https://blog.csdn.net/weixin_36751895/article/details/79303854


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM