数据表未在chrome中显示excel按钮

时间:2017-08-31 13:19:10

标签: datatables

我正在为我的数据表添加export excel按钮,如下所示:

buttons: [
    {
      extend: "colvis",
      className: "btn-sm",
      columns: [ 1, 3, 4, 6, 7, 8, 9, 10, 11, 13, 15,17,19,21,23,25,27,29,31,33 ]
    },
    {
      extend: "pageLength",
      className: "btn-sm"
    },
    {
      extend: "csv",
      className: "btn-sm",
      exportOptions: {
          columns: ':visible'
      }
    },
    {
      extend: "excel",
      className: "btn-sm",
      exportOptions: {
          columns: ':visible'
      }
    },
    {
      extend: "print",
      className: "btn-sm",
      exportOptions: {
          columns: ':visible'
      }
    },
  ],

在所有按钮的Internet Explorer中工作正常,但对于chrome,我没有看到excel按钮。

我不幸在控制台中看到错误......

1 个答案:

答案 0 :(得分:-1)

我遇到了同样的问题,并在我的文件中添加了以下脚本,然后它开始显示按钮。

https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js

我希望你已经添加了flash,html5和print脚本。总体而言,您的脚本代码如下所示。

https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js
https://cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js
https://cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js
https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js
https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js
https://cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js
https://cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js

您可以查看工作示例here