1. demo.html
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TABLE轉(zhuǎn)換EXCEL</title>
<script src="jquery.min.2.2.4.js" ></script>
<script src="table2excel.js"></script>
<style type="text/css">
.btn{
margin:20px;
}
</style>
</head>
<body>
<center>
<div class="table2excel">
<table id = 'testTable' border="1">
<tr>
<td colspan="3"><input class="btn" type="button" value="點擊導(dǎo)出"></td>
</tr>
<tr>
<th>標(biāo)題一</th>
<th>標(biāo)題二</th>
<th>標(biāo)題三</th>
</tr>
<tr class="noExl">
<td>100 (不導(dǎo)出)</td>
<td>200 (不導(dǎo)出)</td>
<td>300 (不導(dǎo)出)</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
</table>
</div>
</center>
<script type="text/javascript">
$(function() {
$(".btn").click(function(){
$(".table2excel").table2excel({
// 不被導(dǎo)出的表格行的CSS class類
exclude: ".noExl",
// 導(dǎo)出的Excel文檔的名稱
name: "Excel Document Name",
// Excel文件的名稱
filename: "test",
//文件后綴名
fileext: ".xls",
//是否排除導(dǎo)出圖片
exclude_img: false,
//是否排除導(dǎo)出超鏈接
exclude_links: false,
//是否排除導(dǎo)出輸入框中的內(nèi)容
exclude_inputs: false
});
});
});
</script>
</body>
</html>
其他資源文件(js)網(wǎng)上一搜一大把,也可以下載我上傳的,文章來源:http://www.zghlxwxcb.cn/news/detail-527001.html
但是有個重大bug就是當(dāng)列多時(通常超過20列),數(shù)據(jù)一般超過600條就會造成瀏覽器無反應(yīng)文章來源地址http://www.zghlxwxcb.cn/news/detail-527001.html
到了這里,關(guān)于頁面的table直接轉(zhuǎn)excel并下載(不需要經(jīng)過后臺)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!