In the project, to save a Table in the page to Excel, the code is as follows:
Html code
<html>
<head>
<title>Save Table in HTML to Excel</title>
</head>
<body>
<h1>Save content to Excel</h1>
<table id='content'>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
<tr><td>Column 1</td><td>Column 2</td></tr>
</table>
<a href="javascript:downloadfile('content')">Save file</a>
<script language="javascript">
function downloadfile(id)
{
window.document.write(document.getElementById(id).outerHTML);
window.document.execCommand("SaveAs",false,"C:\download.xsl");
history.go(-1);
}
</script>
</body>
</html>