I want to give Download Excel button this table i want in excel
Internet exploer extension not coming
here ASHA,ANM,Mother is dynamically coming from db
<table class="table table-bordered">
<thead>
<tr class="tblhead">
<th>State Name</th>
<th colspan="2">Mother</th>
<th colspan="2">ASHA</th>
<th colspan="2">ANM</th>
</tr>
</thead>
<tbody>
<tr>
<td> </td>
<td>Count</td>
<td>Payment</td>
<td>Count</td>
<td>Payment</td>
<td>Count</td>
<td>Payment</td>
</tr>
<tr>
<td width="20%"><a>Andhra Pradesh</a></td>
<td width="10%">22</td>
<td width="10%">₹ 30,800</td>
<td width="10%">57</td>
<td width="10%">₹ 12,450</td>
<td width="10%">32</td>
<td width="10%">₹ 7,250</td>
</tr>
<tr>
<td width="20%"><a>Arunachal Pradesh</a></td>
<td width="10%">24</td>
<td width="10%">₹ 54,545</td>
<td width="10%">12</td>
<td width="10%">₹ 65,655</td>
<td width="10%">23</td>
<td width="10%">₹ 89,815</td>
</tr>
<tr>
<td width="20%"><a>Assam</a></td>
<td width="10%">45</td>
<td width="10%">₹ 304,800</td>
<td width="10%">56</td>
<td width="10%">₹ 12,450</td>
<td width="10%">56</td>
<td width="10%">₹ 7,250</td>
</tr>
</tbody>
</table>
What I have tried:
function fnExcelReport() {
var tab_text = "<table border="2px"><tr bgcolor="#87AFC6">";
var textRange; var j = 0;
tab = document.getElementById('tblTesting');
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, "");
tab_text = tab_text.replace(/<img[^>]*>/gi, "");
tab_text = tab_text.replace(/<input[^>]*>|<\/input>/gi, "");
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
{
txtArea1.document.open("txt/html", "replace");
txtArea1.document.write(tab_text);
txtArea1.document.close();
txtArea1.focus();
sa = txtArea1.document.execCommand("SaveAs", true, "Activity.xls");
return (sa);
}
else {
var a = document.createElement('a');
a.href = 'data:application/vnd.ms-excel,' + encodeURIComponent(tab_text);
a.download = 'exported_table.xls';
a.click();
e.preventDefault();
}
}