版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创!
恰饭广告
注意:
1、导出的Excel默认为xlsx,如需修改请到jsonToExcel中查找修改即可
2、数据量大的不建议使用此方法,否则会导致页面奔溃(可以采用后台生成excel,而不是前台)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https://www.idaobin.com/js/jquery-3.2.1.js"></script> <script src="https://www.idaobin.com/js/xlsx.full.min.js"></script> <script src="https://www.idaobin.com/js/FileSaver.min.js"></script> <script src="https://www.idaobin.com/js/jsonToExcel.js"></script> <script> $(document).ready(function () { $('#export').click(function () { //json测试数据 var students = [{ "name": "daobin", "course": "网站前端技术", "dept": "软件系" }, { "name": "张三", "course": "linux", "dept": "软件系" }, { "name": "李四", "course": "j2ee", "dept": "软件系" }]; //导出 downloadExecl(students,"导出文件名"); }); }); </script> </head> <body> <input type="button" value="导出" id="export"> </body> </html>
原文链接:https://www.idaobin.com/archives/1973.html
让我恰个饭吧.ヘ( ̄ω ̄ヘ)
恰饭广告