此demo使用tableexport可在火狐浏览器中导出excel中文无乱码
<!DOCTYPE html><html lang="en"><head><title>Matrix Admin</title><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><link rel="stylesheet" href="css/bootstrap.min.css" /><link rel="stylesheet" href="css/bootstrap-responsive.min.css" /><link rel="stylesheet" href="css/uniform.css" /><link rel="stylesheet" href="css/select2.css" /><link rel="stylesheet" href="css/matrix-style.css" /><link rel="stylesheet" href="css/matrix-media.css" /><link href="font-awesome/css/font-awesome.css" rel="stylesheet" /><link href='http://fonts.googleapis.com/css?family=Open Sans:400,700,800' rel='stylesheet' type='text/css'> <script src="js/jquery.min.js"></script> <script src="js/jquery.ui.custom.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/jquery.uniform.js"></script> <script src="js/select2.min.js"></script> <script src="js/jquery.dataTables.min.js"></script> <script src="js/matrix.js"></script> <script src="tableExport/jquery.base64.js"></script> <script src="tableExport/tableExport.js"></script> <script type="text/javascript"> function DaoChu() { $('#tb_user').tableExport({ type: 'excel', escape: 'false' }); } </script></head><body><!--Header-part--><div id="header"> <h1><a href="dashboard.html">Matrix Admin</a></h1></div><!--close-Header-part--> <!--top-Header-menu--><div id="user-nav" class="navbar navbar-inverse"> <ul class="nav"> <li class="dropdown" id="profile-messages" ><a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"><i class="icon icon-user"></i> <span class="text">Welcome User</span><b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="#"><i class="icon-user"></i> My Profile</a></li> <li class="divider"></li> <li><a href="#"><i class="icon-check"></i> My Tasks</a></li> <li class="divider"></li> <li><a href="login.html"><i class="icon-key"></i> Log Out</a></li> </ul> </li> <li class="dropdown" id="menu-messages"><a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle"><i class="icon icon-envelope"></i> <span class="text">Messages</span> <span class="label label-important">5</span> <b class="caret"></b></a> <ul class="dropdown-menu"> <li><a class="sAdd" title="" href="#"><i class="icon-plus"></i> new message</a></li> <li class="divider"></li> <li><a class="sInbox" title="" href="#"><i class="icon-envelope"></i> inbox</a></li> <li class="divider"></li> <li><a class="sOutbox" title="" href="#"><i class="icon-arrow-up"></i> outbox</a></li> <li class="divider"></li> <li><a class="sTrash" title="" href="#"><i class="icon-trash"></i> trash</a></li> </ul> </li> <li class=""><a title="" href="#"><i class="icon icon-cog"></i> <span class="text">Settings</span></a></li> <li class=""><a title="" href="login.html"><i class="icon icon-share-alt"></i> <span class="text">Logout</span></a></li> </ul></div><!--start-top-serch--><div id="search"> <input type="text" placeholder="Search here..."/> <button type="submit" class="tip-bottom" title="Search"><i class="icon-search icon-white"></i></button></div><!--close-top-serch--> <!--sidebar-menu--><div id="sidebar"> <a href="#" class="visible-phone"><i class="icon icon-th"></i>Tables</a> <ul> <li class="active"><a href="tables.html"><i class="icon icon-th"></i> <span>Tables</span></a></li> </ul></div><div id="content"> <div id="content-header"> <div id="breadcrumb"> <a href="#" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a> <a href="#" class="current">Tables</a> </div> <h1>Tables</h1><button type="button" onclick="DaoChu()" class="tip-bottom" title="Search"><i class="icon-search icon-white">导出</i></button> </div> <div class="container-fluid"> <hr> <div class="row-fluid"> <div class="span12"> <div class="widget-box"> <div class="widget-title"> <span class="icon"> <i class="icon-th"></i> </span> <h5>Static table</h5> </div> <div class="widget-content nopadding"> <table class="table table-bordered table-striped" id="tb_user"> <thead> <tr> <th>姓名</th> <th>国籍</th> <th>电话</th> <th>性别</th> <th>年龄</th> </tr> </thead> <tbody> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> <tr class="odd gradeX"> <td>张三</td> <td>中国</td> <td>13800000000</td> <td class="center">男</td> <td class="center">28</td> </tr> </tbody> </table> </div> </div> </div> </div> </div></div><!--Footer-part--><div class="row-fluid"> <div id="footer" class="span12"> Themedesigner.in </div></div><!--end-Footer-part--></body></html>
评论