Simplest way using Jquery
Just add this:
<script src="https://cdn.jsdelivr.net/gh/linways/[email protected]/dist/tableToExcel.js"></script>
Then add Jquery script:
<script type="text/javascript">
$(document).ready(function () {
$("#exportBtn1").click(function(){
TableToExcel.convert(document.getElementById("tab1"), {
name: "Traceability.xlsx",
sheet: {
name: "Sheet1"
}
});
});
});
</script>
Then add HTML button:
<button id="exportBtn1">Export To Excel</button><br><br>
Note: "exportBtn1"
will be button ID and
"tab1" will be table ID