Export HTML Table

Want to provide an export function in your code for html tables?  Here is a small code snippet to accomplish this task.

Include this function anywhere you are providing Javascript code to your file:

function ExportToExcel(mytblId){
    var htmltable= document.getElementById(mytblId);
    var html = htmltable.outerHTML;
    window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));

Then include the following button on your page:

<input class="mybutton" type="button" value="Export to Excel" onclick="ExportToExcel('myTableId')">