<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TABLE轉換EXCEL</title>
<script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js" ></script>
<script src="js/jquery.table2excel.js"></script>
<style type="text/css">
.btn{
margin:20px;
}
</style>
</head>
<body>
<center>
<input class="btn" type="button" value="點擊導出">
<div class="table2excel">
<table id = 'testTable' border="1">
<tr>
<th>標題一</th>
<th>標題二</th>
<th>標題三</th>
</tr>
<tr class="noExl">
<td>100 (不導出)</td>
<td>200 (不導出)</td>
<td>300 (不導出)</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
<tr>
<td><a href="http://www.baidu.com">baidu.com</a></td>
<td><input tyle="text" value="input 數據"></td>
<td><img src="http://yuyuan:8080/zzz/img/test.jpg" alt="image"></td>
</tr>
</table>
</div>
</center>
<script type="text/javascript">
$(function() {
$(".btn").click(function(){
$(".table2excel").table2excel({
// 不被導出的表格行的CSS class類
exclude: ".noExl",
// 導出的Excel文檔的名稱
name: "Excel Document Name",
// Excel文件的名稱
filename: "test",
//文件后綴名
fileext: ".xls",
//是否排除導出圖片
exclude_img: false,
//是否排除導出超鏈接
exclude_links: false,
//是否排除導出輸入框中的內容
exclude_inputs: false
});
});
});
</script>
</body>
</html>
原文鏈接 : https://blog.csdn.net/weixin_36751895/article/details/79303854
