我想在 DataTable 中实现 excel 图标而不是 excel 导出选项的按钮。我已经放置了表格工具参考并尝试实现导出 excel 表。
- 如何使用excel图标而不是按钮?
- 是否有可能设计 excel 表标题和表格格式?
- 如何将导出按钮移动到表格的右侧?
请看演示
var oTable = $("#products1").dataTable({
"aaData": newarray,
"bProcessing": true,
"bDeferRender": true,
"bFilter": false,
"bRetrieve": true,
"bPaginate": true,
"bJQueryUI": true,
"sPaginationType": "two_button",
"sDom": '<"H"Tfr>t<"F"ip>',
"oTableTools": {
"sSwfPath": "../images/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "xls",
"sFileName": "*.xls"
}]
},
"bSort": true,
"aaSorting": [[2, 'asc']],
"iDisplayLength": 5,
"aoColumns": [{"sWidth": "135px","sClass": "center","bSortable": true},{
"sWidth": "145px","sClass": "center","bSortable": true},{
"sWidth": "20px","sClass": "center","bSortable": false},{
"sWidth": "145px","sClass": "center","bSortable": false}
],
"aoColumnDefs": [{ "fnRender": function (o, val) {
return o.aData[0];
},
"sClass": "","aTargets": [0]
}, {
"fnRender": function (o, val) {
return o.aData[1];
},
"sClass": "","aTargets": [1]
}, {
"fnRender": function (o, val) {
return o.aData[2];
},
"sClass": "Number","aTargets": [2]
},{
"fnRender": function (o, val) {
return o.aData[3];
},
"sClass": "Description","aTargets": [3]
}]
});