-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
30 lines (27 loc) · 974 Bytes
/
test.html
File metadata and controls
30 lines (27 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<html>
<body>
<button id='download'>Download</button>
<table id='table'>
<tr>
<td style="color:red" >Hello praveen</td>
</tr>
</table>
<script src="./jszip_sync.js"></script>
<script src="./xlsx.js"></script>
<script>
document.getElementById("download").addEventListener( "click", function() {
var workbook = XLSX.utils.book_new();
var ws1 = XLSX.utils.table_to_sheet(document.getElementById('table'));
XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1");
var wopts = { bookType:'xlsx', bookSST:false, type:'array' };
var wbout = XLSX.write(workbook,wopts);
var a=document.createElement("a");
a.setAttribute("href",URL.createObjectURL(new Blob([wbout],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})));
a.setAttribute("download","test.xlsx");
a.style='display:none;'
document.querySelector("body").appendChild(a);
a.click();
});
</script>
</body>
</html>