<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery HTML表格生成Excel文件插件</title>
<link rel="stylesheet" href="http://view.jqueryfuns.com/预览-/2014/9/16/98cd924512db6719204bea8b39a78b09/css/bootstrap/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/demo.css">
</head>
<body>
<section class="demo">
<div class="container" style="padding:30px 0">
<div class="row">
<div class="md-col-8">
<div class="table-responsive table2excel" data-tableName="Test Table 1">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr class="noExl">
<td class="danger">带<code>noExl</code>class的行不会被输出到excel中</td>
<td class="danger">带<code>noExl</code>class的行不会被输出到excel中</td>
</tr>
<tr>
<td class="success">这一行会被导出到excel中</td>
<td class="success">这一行会被导出到excel中</td>
</tr>
</thead>
<tbody>
<tr>
<td>单元格1-1</td>
<td>单元格1-2</td>
</tr>
<tr>
<td>单元格2-1</td>
<td>单元格2-2</td>
</tr>
<tr>
<td>单元格3-1</td>
<td>单元格3-2</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2" class="warning">合并2个单元格</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<button id="btn" class="btn btn-primary">点击这里将表格内容导出到excel中</button>
</div>
</section>
<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="dist/jquery.table2excel.js"></script>
<script>
$(function() {
$("#btn").click(function(){
$(".table2excel").table2excel({
exclude: ".noExl",
name: "Excel Document Name",
filename: "myFileName",
exclude_img: true,
exclude_links: true,
exclude_inputs: true
});
});
});
</script>
</body>
</html>