使用jquery插件 jquery.table2excel.js 将页面中的表格下载到本地(excel格式)

来源:互联网 发布:淘宝宝贝七天下架吗 编辑:程序博客网 时间:2024/05/17 18:18

使用jquery插件 jquery.table2excel.js 将页面中的表格下载到本地

首先, 导入js插件:

这里写图片描述
并将js文件导入到jsp中;

其次, js 文件中下载表格代码如下:

    $("#btn").click(function(){        $(".table2excel").table2excel({            exclude: ".noExl",            name: "Excel Document Name",            filename: "myFileName",            exclude_img: true,            exclude_links: true,            exclude_inputs: true        });    });

注释: (“#btn”) 表示触发下载事件的标签选择器,(“.table2excel”) 表示表格标签,
exclude: “.noExl” : 有class = “noExl” 的行不被导出;
最后,导出的excel 文件 如下:

jquery-table2excel插件的github地址为: https://github.com/rainabba/jquery-table2excel

0 0