我使用了https://www.datatables.net示例 以下是我的jQuery
<script type="text/javascript">$(document).ready(function () {var data = <%=liveProjectData %>
$("#empdetails").html('<table id="example" class="table-responsive table-bordered table-hover" ></table>');
$("#example").dataTable({
"oTableTools": {
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf",
"aButtons": ["xls", "pdf", "print"]
},
"columns": [{
"title": "A"
}, {
"title": "B"
}, {
"title": "C"
}, {
"title": "D"
}, {
"title": "E"
}
],
"data": function () {
return $.map(data, function (attribute) {
return [
["<div class='badge badge-" + attribute.A + "'>" + attribute.A + "</div>", attribute.B, attribute.C, attribute.D, attribute.E, '<a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="EditProjectDetails(' + attribute.A + ')">EDIT</a>'] ] })}()}) }); function EditProjectDetails(A) { window.location = "viewClientDetailToAdmin.aspx?A=" + A };
我已将数据绑定到以下div
<div class="row"> <div class="col-md-12" id="empdetails"></div></div>
我在https://www.datatables.net/extensions/tabletools/阅读了有关数据表工具的内容 它将HTML表格数据导出为pdf,excel
请帮我在Excel中下载我已绑定的HTML表格。
提前感谢...
答案 0 :(得分:1)
有三种方法可以实现它: