部署时导出到 Excel 不起作用 [英] Export to Excel not working when deployed

查看:38
本文介绍了部署时导出到 Excel 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我用来创建具有导出功能的数据表的代码.

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.

推荐答案

sSwfPath 更改为绝对路径.

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"]
}

此处使用数据表 CDN.问题是,当您部署到 IIS 或正在使用的任何 Windows 平台时,相对路径会混乱.这是一个非常普遍的问题.

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.

这篇关于部署时导出到 Excel 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆