jquery.table2excel.min.js
is jquery library which has inbuilt functionality to expert any HTML table to
Excel file by table id. This is one of the simplest solutions available on the internet totally
free of cost.
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Girfa HTML to Excel</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>
<script src="https://cdn.rawgit.com/rainabba/jquery-table2excel/1.1.0/dist/jquery.table2excel.min.js"> </script>
<script>
function tbltoexcel()
{
$("#studtable").table2excel({
filename: "Students.xls"
});
}
</script>
</head>
<body>
<button onClick="tbltoexcel()">Export</button>
<table id="studtable" onClick="tbl()">
<thead>
<tr>
<td class="noExport">
This cell will not be
exported.
</td>
<td>
This cell will get
exported.
</td>
</tr>
</thead>
<tbody>
<tr>
<td>Raj</td>
<td class="noExport">Varanasi</td>
</tr>
<tr>
<td>Amit</td>
<td>Alld</td>
</tr>
<tr>
<td>Sumit</td>
<td>BLP</td>
</tr>
</tbody>
</table>
</body>
</html>
No comments:
Post a Comment