2017-03-09 85 views
0

即使我使用上面的代码,我的导出到Excel按钮仍然不显示。我不知道这些代码发生了什么。有更多经验的人请帮助我。我从https://datatables.net/extensions/buttons/examples/initialisation/export.html导出到Excel按钮不显示

 <table id="example" class="display nowrap" 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> 
     <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> 
      <tr> 
       <td>Ashton Cox</td> 
       <td>Junior Technical Author</td> 
       <td>San Francisco</td> 
       <td>66</td> 
       <td>2009/01/12</td> 
       <td>$86,000</td> 
      </tr> 
     </tbody> 
    </table> 

<script> 
    $(document).ready(function() { 
     $('#example').DataTable({ 
      dom: 'Bfrtip', 
      buttons: [ 
       'excel' 
      ] 
     }); 
    }); 
</script> 

这里有我引用的控制台输出:

enter image description here

+0

1)我们是否真的需要在你的例子中看到你所有的行?保持在最低限度! 2)打开你的浏览器的开发者控制台,运行你的代码,并让我们,如果你有任何控制台错误。 3)将这些添加到您的问题。 –

+1

@LeeTaylor对不起,先生,这是我第一次..我更新了我的问题 btw感谢您的提示 – coposaja

回答

0

为了您使用导出插件,您还需要包括以下脚本:

//code.jquery.com/jquery-1.12.4.js https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js //cdn.datatables.net/buttons/1.2.4/js/buttons.flash.min.js //cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js //cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/pdfmake.min.js //cdn.rawgit.com/bpampuch/pdfmake/0.1.24/build/vfs_fonts.js //cdn.datatables.net/buttons/1.2.4/js/buttons.html5.min.js //cdn.datatables.net/buttons/1.2.4/js/buttons.print.min.js

这你所提供的链接中详细说明。查看该页面的来源,了解它们是如何包含它们的。

+0

其实我已经做到了..我已经包括这些脚本..我把这些之间的结束我的表和那个脚本标记..它是错误的地方? – coposaja

+0

我认为你需要检查脚本,表格和其他标签的顺序。将此与链接版本进行比较。另外,您可能需要在网络服务器上运行,是吗? –

+1

谢谢你的所有帮助,然后先生..我会尝试重新检查他们,然后.. – coposaja