Showing posts with label Export HTML table using jQuery. Show all posts
Showing posts with label Export HTML table using jQuery. Show all posts

Sunday, March 7, 2021

Export html table using jQuery

If you need to export HTML table data to Excel Table to Excel 2 plugin can be used.

Its pretty simple.  Just add

Include JS

<script type="text/javascript" src="../dist/tableToExcel.js"></script>

javascript

<script type="text/javascript">
  $(function () {
      $("#btnExport").click(function(){
        TableToExcel.convert(document.getElementById("table1"), {
            name: "download.xlsx",
            sheet: {
            name: "Sheet1"
            }
          });
        });
  });
</script>
 
Add html Button

<button id="btnExport">Export To Excel</button><br><br>
 
Regards
Samitha