簡體   English   中英

通過數據表在Mozilla中導出PDF或Excel

[英]Export PDF or Excel in Mozilla by datatable

我正在通過數據表使用導出功能。 這在Chrome瀏覽器中有效。 但是,在通過Mozilla瀏覽器導出時,出現[[object Object]”錯誤。

在Mozilla瀏覽器中單擊導出時,這是錯誤:

圖片

使用API​​數據表的所需示例。

 $(document).ready(function() { $('#table_id').DataTable( { dom: 'Bfrtip', buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print' ] } ); } ); 
 /* * Table */ table.dataTable { margin: 0 auto; clear: both; width: 100%; } table.dataTable thead th { padding: 3px 18px 3px 10px; border-bottom: 1px solid black; font-weight: bold; cursor: pointer; *cursor: hand; } table.dataTable tfoot th { padding: 3px 18px 3px 10px; border-top: 1px solid black; font-weight: bold; } table.dataTable td { padding: 3px 10px; } table.dataTable td.center, table.dataTable td.dataTables_empty { text-align: center; } table.dataTable tr.odd { background-color: #E2E4FF; } table.dataTable tr.even { background-color: white; } table.dataTable tr.odd td.sorting_1 { background-color: #D3D6FF; } table.dataTable tr.odd td.sorting_2 { background-color: #DADCFF; } table.dataTable tr.odd td.sorting_3 { background-color: #E0E2FF; } table.dataTable tr.even td.sorting_1 { background-color: #EAEBFF; } table.dataTable tr.even td.sorting_2 { background-color: #F2F3FF; } table.dataTable tr.even td.sorting_3 { background-color: #F9F9FF; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="<script src = "https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/dataTables.buttons.min.js"></script> <script src="https://cdn.datatables.net/buttons/1.3.1/js/buttons.flash.min.js"></script> <script src = "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src = "https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/pdfmake.min.js"></script> <script src= "https://cdn.rawgit.com/bpampuch/pdfmake/0.1.27/build/vfs_fonts.js"></script> <script src= "https://cdn.datatables.net/buttons/1.3.1/js/buttons.html5.min.js"></script> <script src= "https://cdn.datatables.net/buttons/1.3.1/js/buttons.print.min.js"></script> <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css"/> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.3.1/css/buttons.dataTables.min.css"/> <div> <table id="table_id"> <thead> <tr> <th>Name</th> <th>Age</th> <th>Bot</th> </tr> </thead> <tbody> <tr> <td>John</td> <td>25</td> <td><button type="button" id="myBtn_1">Select</button></td> </tr> <tr> <td>Ana</td> <td>22</td> <td><button type="button" id="myBtn_2">Select</button></td> </tr> <tr> <td>Diana</td> <td>23</td> <td><button type="button" id="myBtn_3">Select</button></td> </tr> <tr> <td>Lino</td> <td>32</td> <td><button type="button" id="myBtn_4">Select</button></td> </tr> </tbody> </table> </div> 

重要筆記:

某些功能可能無法在摘要中使用(打印);

需要初始化,沒有初始化,代碼將無法工作。

有關更多信息,請訪問以下鏈接: https : //datatables.net/extensions/buttons/examples/initialisation/export.html

如有任何疑問,請尋求我的幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM