How can I convert multiple html tables to an excel sheet with multiple worksheets? Could you please help into this.
My example https://jsfiddle.net/kdkd/5p22gdag/>
function tablesToExcel() {
{
var tab_text = document.getElementById("MsoNormalTable").outerHTML;
var textRange; var j = 0;
var tab = document.getElementById('MsoNormalTable'); // id of table
var sa;
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
var txt = document.getElementById('txtArea1').contentWindow;
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer
{
txt.document.open("txt/html", "replace");
txt.document.write(tab_text);
txt.document.close();
txt.focus();
sa = txt.document.execCommand("SaveAs", true, "Say Thanks to Sumit.xls");
}
else //other browser not tested on IE 11
sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text));
return (sa);
}
}
It is working with IE7+ fine... :)