massExcel.html
1.5 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>HTML table Export</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="../libs/FileSaver/FileSaver.min.js"></script>
<script type="text/javascript" src="../tableExport.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var Table = document.getElementById ( 'container' );
var T = [];
var r = 0;
var c = 1;
var rmax = 3289;
var cmax = 26;
T.push('<table id="grid">');
T.push('<thead>');
T.push('<tr>');
T.push('<th>col #</th>');
while (++c <= cmax+1)
T.push('<td>col ' + c + '</td>');
T.push('</tr>');
T.push('</thead>');
T.push('<tbody>');
while (r++ < rmax) {
c = 0;
T.push('<tr>');
T.push('<td>' + r + '</td>');
while (c++ < cmax)
T.push('<td>' + getRandomInt(100,10000) + '</td>');
T.push('</tr>');
}
T.push('</tbody>');
T.push('</table>');
Table.innerHTML = T.join ("");
$('#export').click(function() {
$('#grid').tableExport({type:'excel', excelstyles:['border-bottom', 'border-top', 'border-left', 'border-right']});
});
});
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
</script>
</head>
<body>
<button id="export">Export to Excel</button>
<div id="container">
</div>
</body>
</html>