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>
Share:
13,723
Aman Taneja
Author by

Aman Taneja

Updated on June 18, 2022

Comments

  • Aman Taneja
    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
    Aman Taneja about 9 years
    Worked. Thanks a lot. But how can i download the PDF file?
  • Jonathan
    Jonathan about 9 years
    Hmm... 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
    Nischal Kumar BC about 9 years
    It downloads as an Unknown file type, even though file type is provided. Any fix for that?
  • Himalaya Garg
    Himalaya Garg over 5 years
    How to export multiple html tables into multiple sheets in same excel using tableexport.js?