Below is my sample code for exporting the HTML table to excel :
<!DOCTYPE HTML>
<html>
<head>
<script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" >
</script>
<script>
$(function(){
$('button').click(function(){
var dvData = $('#dvData').html();
window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
})
})
</script>
</head>
<body>
<button>
Export To Excel
</button>
<div id="dvData">
<table>
<th> ID </th>
<th> Name </th>
<tr>
<td>"1.0"</td>
<td>string1</td>
</tr>
<tr>
<td>10</td>
<td>string2</td>
</tr>
</table>
</div>
</body>
</html>
This exports 1.0 as 1 in excel which is wrong. I tried adding single quotes but that appears in the webpage which I don't want.