Export to Excel not working when deployed

China☆狼群 提交于 2019-12-02 10:06:48

问题


This is the code I used to create a data table with export functionality.

oTable = $("#tblSearch").DataTable({
    "jQueryUI": true,
    "sPaginationType": "full_numbers",
    "iDisplayLength": 10,
    "bSort": true,
    "aaSorting": [[0, "desc"]],
    "lengthMenu": [[5, 10, 25, 50], [5, 10, 25, 50]],
    "autoWidth": true,
    "scrollCollapse": true,
    "dom": 'T<"clear">lfrtip',
    "tableTools": {
        "sSwfPath": "../../swf/copy_csv_xls.swf",
        "aButtons": ["xls"]
    }
});

Export is working in my local but when I deployed in server, the button does not appear.


回答1:


Change the sSwfPath to an absolute path.

"tableTools": {
    "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.3/swf/copy_csv_xls_pdf.swf",
    "aButtons": ["xls"]
}

here using the dataTables CDN. The problem is, that the relative path messes up when you deploy to your IIS or whatever windows platform you are using. This is a very common problem.



来源:https://stackoverflow.com/questions/28690052/export-to-excel-not-working-when-deployed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!