JSFiddle - React, Tailwind, and code Playground

HTML

<iframe id="txtArea1"></iframe>

<input type="button" id="btnExport" onclick="exportToExcelMsIe()" value="Export"/>

<table id="testTable"><tr><td>Hello World</td></tr></table>

JavaScript

function exportToExcelMsIe() {
  
	var tab_text="<table border='2px'><tr bgcolor='#87AFC6'>";
	var textRange; var j=0;
	var tab = document.getElementById('testTable'); // id of table

	for(j = 0 ; j < tab.rows.length ; j++) 
	{     
		tab_text=tab_text+tab.rows[j].innerHTML+"</tr>";
	}

	tab_text=tab_text+"</table>";
	tab_text= tab_text.replace(/<A[^>]*>|<\/A>/g, "");//remove if u want links in your table
	tab_text= tab_text.replace(/<img[^>]*>/gi,""); // remove if u want images in your table
	tab_text= tab_text.replace(/<input[^>]*>|<\/input>/gi, ""); // reomves input params


	var txtArea1 = document.getElementById('txtArea1');
	txtArea1.contentWindow.document.open("txt/html","replace");
	txtArea1.contentWindow.document.write(tab_text);
	txtArea1.contentWindow.document.close();
	txtArea1.contentWindow.focus(); 
	var sa=txtArea1.contentWindow.document.execCommand("SaveAs",true,"IE Excel Export.xls");
};