Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Datatables jquery数据表pdf&;xls报告生成不工作_Datatables - Fatal编程技术网

Datatables jquery数据表pdf&;xls报告生成不工作

Datatables jquery数据表pdf&;xls报告生成不工作,datatables,Datatables,我正在尝试使用jQueryDataTable生成xls、csv、pdf报告,但它不起作用 <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css"> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcd

我正在尝试使用jQueryDataTable生成xls、csv、pdf报告,但它不起作用

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">
下面是示例代码。 css和js链接是

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">

以下是onload函数:

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">
<script type="text/javascript">

            $(document).ready(function () {
           $('#example').dataTable({
                    "sDom": 'T<"clear">lfrtip',
                    "oTableTools": {

                        "sSwfPath": "https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf",
                        "aButtons": [
                            {
                                "sExtends":    "collection",
                                "sButtonText":"Save / Print",
                                "sPdfMessage": "My Report",
                                "sTitle": "My Report",
                                "aButtons":    [ "xls", "pdf","print" ]
                            }
                        ]
                    }
                });
            });
</script>

$(文档).ready(函数(){
$('#示例')。数据表({
“sDom”:“Tlfrtip”,
“可旋转工具”:{
“sSwfPath”:https://cdn.datatables.net/tabletools/2.2.4/swf/copy_csv_xls_pdf.swf",
“阿布顿”:[
{
“性倾向”:“收藏”,
“sButtonText”:“保存/打印”,
“sPdfMessage”:“我的报告”,
“缝合”:“我的报告”,
“阿布顿”:[“xls”、“pdf”、“打印”]
}
]
}
});
});
下表如下:

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">
<div style="padding:1%">

<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>Name</th>
                <th>Position</th>
                <th>Office</th>
                <th>Age</th>
                <th>Start date</th>
                <th>Salary</th>
            </tr>
        </tfoot>
        <tbody>
            <tr>
                <td>Tiger Nixon</td>
                <td>System Architect</td>
                <td>Edinburgh</td>
                <td>61</td>
                <td>2011/04/25</td>
                <td>$320,800</td>
            </tr>
            <tr>
                <td>Garrett Winters</td>
                <td>Accountant</td>
                <td>Tokyo</td>
                <td>63</td>
                <td>2011/07/25</td>
                <td>$170,750</td>
            </tr>


        </tbody>
    </table>

    </div>

名称
位置
办公室
年龄
开始日期
薪水
名称
位置
办公室
年龄
开始日期
薪水
老虎尼克松
系统架构师
爱丁堡
61
2011/04/25
$320,800
加勒特温特斯
会计
东京
63
2011/07/25
$170,750
不明白是什么毛病。请帮忙。提前谢谢

您需要安装扩展并遵循新的文档,因为它与以前的版本相比发生了很大变化

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">
下面是我正在使用的一个示例,带有标准按钮

<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/tabletools/2.2.4/css/dataTables.tableTools.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css">
dataTable = $('#myTable').DataTable({
                    dom: '<"col-md-7"lr><"col-md-3"B><"col-md-2"f>tr<"col-md-8"i><"col-md-4"p>',
ajax: {
        url: myHandler,
        type: "POST",
    },
    lengthMenu: [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ],
    buttons: ['copy', 'excel', 'pdf', 'print'],
    serverSide: true,
    processing: true,
    autoWidth: true,
    deferRender: true,
});
dataTable=$('#myTable')。dataTable({
dom:‘tr’,
阿贾克斯:{
url:myHandler,
类型:“POST”,
},
长度菜单:[[10,25,50,100,-1],[10,25,50,100,“全部”],,
按钮:[“复制”、“excel”、“pdf”、“打印”],
服务器端:是的,
处理:对,
自动宽度:正确,
是的,
});

在链接中有许多非工作示例。请参阅:谢谢..但我正在尝试:。但工作不正常保存的文件没有任何扩展名