Export HTML table to PDF, WORD, PNG using TableExport.js
13,723
Include any scripts reliant on jQuery after the jQuery. I'd say best practice is to put jQuery first. Let me know if this works:
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript" src="./js/tableExport.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="js/sprintf.js"></script>
<script type="text/javascript" src="js/jspdf.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
Author by
Aman Taneja
Updated on June 18, 2022Comments
-
Aman Taneja almost 2 years
I am trying to export a Table via PDF using the js provided by Ngiriraj Table Export Demo. The code is:
<!DOCTYPE html> <html> <head> <meta charset="ISO-8859-1"> <script type="text/javascript" src="./js/tableExport.js"></script> <script type="text/javascript" src="js/jquery.base64.js"></script> <script type="text/javascript" src="js/sprintf.js"></script> <script type="text/javascript" src="js/jspdf.js"></script> <script type="text/javascript" src="js/base64.js"></script> <script src="js/jquery-1.10.2.min.js"></script> <script src="js/jquery.mobile-1.4.2.min.js"></script> <title>Insert title here</title> </head> <body> <button id="export" style="height: auto; width: auto;" onClick="$('#tableID').tableExport({type:'pdf',escape:'false'});">Click Here for PDF!</button> <table id="tableID"> <tr> <td>ABC</td> <td>BDE</td> </tr> </table> </body> </html>
However, when I click on the button, nothing happens. Console shows a error UNCAUGHT TYPE ERROR whenever the button is clicked.
-
Aman Taneja about 9 yearsWorked. Thanks a lot. But how can i download the PDF file?
-
Jonathan about 9 yearsHmm... For that I'm not quite sure. I don't know that javascript library at all. At least in Chrome, you'll have a little "save" button in the bottom right. I'm not sure about the other browsers, thought. Perhaps under File > Save?
-
Nischal Kumar BC about 9 yearsIt downloads as an Unknown file type, even though file type is provided. Any fix for that?
-
Himalaya Garg over 5 yearsHow to export multiple html tables into multiple sheets in same excel using tableexport.js?