美文网首页
pvtTable表格插件与table2excel表格下载

pvtTable表格插件与table2excel表格下载

作者: 多多VS串串 | 来源:发表于2017-12-20 18:34 被阅读0次

    <!DOCTYPE html>
    <html>

    <head>
        <meta charset="utf-8" />
        <title></title>
        <script src="js/jquery-2.1.4.min.js" type="text/javascript"></script>
        <script src="js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/pivot.min.js" type="text/javascript"></script>
        <script src="js/tips_data.min.js" type="text/javascript"></script>
        <script src="js/jquery.table2excel.min.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="css/pivot.min.css" />
        <style>
            body {
                font-family: Verdana;
            }
        </style>
    </head>
    
    <body>
        <div id="output" style="overflow: scroll;width: 1000px;height: 500px;"></div>
        <button id="btn">点击下载</button>
        <script type="text/javascript">
            var utils = $.pivotUtilities;
            var heatmap = utils.renderers["Heatmap"];
            var sumOverSum = utils.aggregators["Sum over Sum"];
            //生成表格
            $("#output").pivot(
                utils.tipsData, {
                rows: ["sex", "smoker"],
                cols: ["day", "time"],
                aggregator: sumOverSum(["tip", "total_bill"]),
                renderer: heatmap
            });
            
            //下载
            $('#btn').click(function() {
                $(".pvtTable").table2excel({
                    exclude: ".noExl",
                    name: "Excel Document Name",
                    filename: "<<<<<<<<<<<",
                    fileext: ".xls",
                    exclude_img: true,
                    exclude_links: true,
                    exclude_inputs: false
                });
            })
        </script>
    </body>
    

    </html>

    相关文章

      网友评论

          本文标题:pvtTable表格插件与table2excel表格下载

          本文链接:https://www.haomeiwen.com/subject/xocnwxtx.html