【发布时间】:2016-10-24 05:35:26
【问题描述】:
我使用了 tableTools 插件来导出数据表数据,我已经包含了以下插件
<script src="js/jquery-1.12.3.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/moment/moment.min.js" type="text/javascript"></script>
<script src="js/jquery.dataTables.js" type="text/javascript"></script>
<script src="js/dataTables.tableTools.js"></script>
HTML 代码
<table id="result_table" class="display table table-bordered" cellspacing="0" width="100%"></table>
还有我的初始化部分,
var oTable = $('#result_table').dataTable({
//"iDisplayLength": 50,
//"order" : [[0,"desc"]],
"columnDefs": [
{ "width": "16%", "targets": 1 }
],
"lengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "copy_csv_xls_pdf.swf"
}
});
它保存的 CSV 文件不是 Xls 或 Xlsx 格式,而且 CSV 按钮和 Excel 按钮都只是导出 CSV 文件格式。这是我需要导出 Excel 格式的问题。请分享您的建议或解决方案
【问题讨论】:
-
这种方式我已经尝试过兄弟,但现在我使用了 tableTools 插件,它也可以正常工作,例如 pdf 格式和复制按钮 csv 按钮都工作正常,但 excel 按钮不导出 xls 格式这就是问题..在你的建议链接中没有使用 tableTools 插件
-
你还没有添加所有的js。请同时添加以下js //cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js, //cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake。 min.js, //cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js, //cdn.datatables.net/buttons/1.2.1/js/buttons.html5.min.js
-
包含以上插件后不会改变导出按钮的功能
-
@RahulSingh,只有当 OP 想要使用按钮插件而不是退休的 TableTools 时才具有相关性,我认为他也应该这样做。
标签: php jquery excel datatables tabletools