【问题标题】:DataTable export to excel is not working数据表导出到 excel 不起作用
【发布时间】:2015-02-23 10:29:25
【问题描述】:

我需要我的数据表将数据导出到 Excel 文件,但我正在尝试使用 datatables.net 提供的示例。但我的数据表没有响应该功能。我在这里发布我的代码:

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/dataTables.tableTools.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/metallic.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/jquery-ui.css">

<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/js/zebra_datepicker.js"></script>
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/js/dataTables.tableTools.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="<%=request.getContextPath()%>/js/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script> 
$('#mainTable').dataTable({
    dom: 'T<"clear">lfrtip',
    tableTools: {
       "sSwfPath": "../swf/copy_csv_xls_pdf.swf"
    },
    "scrollY": 300,
    "scrollCollapse": true,
    "jQueryUI": true,
    "aaSorting": [],
}); 

谁来帮帮我..

【问题讨论】:

    标签: jquery datatables jquery-datatables export-to-excel


    【解决方案1】:

    http://jsfiddle.net/Lw5npvyd/

    我之前通过下载 swf 对象并将 sswfpath 引用到该位置来实现这一点。

        Please check the fiddle and change the "sSwfPath"
     with the location of the downloaded
     copy_csv_xls_pdf shockwave flash object.
    

    您可以从https://github.com/DataTables/TableTools/blob/master/swf/copy_csv_xls_pdf.swf下载swf文件

    【讨论】:

      【解决方案2】:
      tableTools: {
          "sSwfPath": "../swf/copy_csv_xls_pdf.swf",
          "aButtons": [
                      {
                         'sExtends':'xls',
                          "sFileName": "*.xls"
                      },
                      'csv','pdf','copy','print'
          ]
      },
      

      【讨论】:

      • 简要解释一下为什么这应该有用..:)
      • 谁能在这方面帮助我,我真的不明白为什么它不起作用
      • 只有打印按钮来了
      • 尝试将 dom 更改为 "dom": 'Tt'
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-28
      • 1970-01-01
      • 2020-07-23
      • 2016-01-05
      • 2019-05-15
      • 1970-01-01
      相关资源
      最近更新 更多