需要利用第三方库:jquery.table2excel.js 下载地址:https://github.com/rainabba/jquery-table2excel 复制代码<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/jquery-3.3.1.min.js"></script> <script src="js/jquery.table2excel.js"></script> </head> <body> <table class="table2excel" border="1" cellspacing="0" width="100%"> <thead> <tr> <th>编号</th> <th>姓名</th> <th>年龄</th> <th>地址</th> <th>用户名</th> <th>邮箱</th> <th>手机号</th> <th>电话号码</th> <th class="ttt">编辑</th> </tr> </thead> <tbody> <tr> <td>编号</td> <td>姓名</td> <td>年龄</td> <td>地址</td> <td>用户名</td> <td>邮箱</td> <td>手机号</td> <td>电话号码</td> <td>编辑</td> </tr> </tbody> </table> <button class="btn">导出excel表格</button> <script> $(function() { $(".btn").click(function(){ $(".table2excel").table2excel({ // 不被导出的表格行的CSS class类 exclude: ".noExl", exclude:".ttt", // 导出的Excel文档的名称 name: "Excel Document Name", // Excel文件的名称 filename: "test", //文件后缀名 fileext: ".xls", //是否排除导出图片 exclude_img: false, //是否排除导出超链接 exclude_links: false, //是否排除导出输入框中的内容 exclude_inputs: false }); }); }); </script> </body> </html>