簡體   English   中英

無法導出到Excel

[英]Can't export to excel

我創建了一個隨機表,並且一直在嘗試將其導出為ex​​cel,csv,pdf,並能夠復制和打印該表。 除了導出到excel之外,我能夠做每件事,而且我不確定我忘記添加的文件是什么。 這是我的代碼:

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script src="jquery.js" type="text/javascript"></script> <script src="jquery.dataTables.js" type="text/javascript"></script> <script src="dataTables.buttons.js" type="text/javascript"></script> <script src="buttons.flash.min.js" type="text/javascript"></script> <script src="buttons.html5.min.js" type="text/javascript"></script> <script src="buttons.print.min.js" type="text/javascript"></script> <script src="flashExport.swf" type="text/javascript"></script> <script src="dataTables.buttons.js" type="text/javascript"></script> <script type="text/javascript" src="https://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> <script type="text/javascript" src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script> <script type="text/javascript" src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script> </head> <body> <table id="demoTable"> <thead> <tr> <th> Name</th> <th> Program</th> <th> Age</th> <th> Homecity</th> </tr> </thead> <tbody> <tr> <td> A</td> <td> Computer Engineering</td> <td> 20 Years old</td> <td> Mississauga</td> </tr> <tr> <td> B</td> <td> Computer Engineering</td> <td> 19 Years old</td> <td> Vancouver</td> </tr> <tr> <td> C</td> <td> Computer Engineering</td> <td> 19 Years old</td> <td> Vancouver</td> </tr> <tr> <td> D</td> <td> Computer Engineering</td> <td> 19 years old</td> <td> Ottawa</td> </tr> </tbody> </table> </body> <script type="text/javascript"> $(function() { $("#demoTable").DataTable({ dom: 'Bfrtip', buttons: ['csv', 'excel', 'pdf', 'copy', 'print'] }); }) </script> 

預先感謝您對我的幫助。

<html>之外的jQuery腳本標簽可能導致其他資源加載出現問題。 您還想確保包含DataTable()初始化/配置的<script>位於<body>標記內,或作為單獨的文件加載到<body><head> 通過檢查實例上的源,我可以確保可以看到每個文件都已從本地文件系統/服務器成功加載。

另外,我將重新評估文件類型為.swf<script>資源,工作示例僅使用.js資源。 如果需要包括.swf文件,則可能需要嵌入它們。 看到這個問題

我在這里創建了一個工作示例包括導出到excel。

希望有幫助!

暫無
暫無

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

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