Export to Excel does not work on deployment

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

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 works in my local, but when I deployed to the server, the button does not appear.

+1
source share
1 answer

Change 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 dataTables CDN. The problem is that the relative path gets confused when deploying to your IIS or to any Windows platform that you are using. This is a very common problem.

+1
source

Source: https://habr.com/ru/post/975753/


All Articles