forked from ecofe/tabletoexcel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·66 lines (57 loc) · 1.28 KB
/
Copy pathindex.html
File metadata and controls
executable file
·66 lines (57 loc) · 1.28 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
63
64
65
66
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
body{font-family: Arial, Helvetica, sans-serif;}
table{border-collapse: collapse}
td,th{border:1px solid #ccc; padding: 2px 5px;}
button{padding: 5px;}
div {
line-height: 3;
}
</style>
<body>
<div>
1、<button id="button1">Create By DOM</button>
</div>
<table id="table">
<tr>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>ecofe</td>
<td>18</td>
</tr>
<tr>
<td>alice</td>
<td>3</td>
</tr>
</table>
<p>tableToExcel.render("table");</p>
<div>
2、<button id="button2">Create By Options</button>
<p>
var arr=[ ['Name','Age','Sex','Country'], ['ecofe','18','male','china'], ['alice','3','female','china'] ]
</p>
</div>
<script src="table-to-excel.js"></script>
<script>
var tableToExcel = new TableToExcel();
document.getElementById('button1').onclick = function () {
tableToExcel.render("table");
};
document.getElementById('button2').onclick = function () {
var arr = [
['Name', 'Age', 'Sex', 'Country'],
['ecofe', '18', 'male', 'china'],
['alice', '3', 'female', 'china']
]
tableToExcel.render(arr, [{ text: "title1", bg: "#333", color: "#fff" }, { text: "title2", bg: "#ddd", color: "#333" }]);
};
</script>
</body>
</html>