-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.html
137 lines (130 loc) · 3.54 KB
/
index.html
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<table id="table1" border="1" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td>序号</td>
<td>姓名</td>
<td>年龄</td>
<td>兴趣</td>
<td>身份证号</td>
<td>手机号</td>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>张三</td>
<td>18</td>
<td>打游戏</td>
<td>320322184087562589</td>
<td>1374569821</td>
</tr>
<tr>
<td>2</td>
<td>李四</td>
<td>88</td>
<td>看电影</td>
<td>420322184087562589</td>
<td>2374569821</td>
</tr>
<tr>
<td>3</td>
<td>王五</td>
<td>81</td>
<td>睡觉</td>
<td>520322184087562589</td>
<td>3374569821</td>
</tr>
<tr>
<td colspan="4">这是一个合并单元格</td>
</tr>
</tbody>
</table>
<button id="btn" onclick="btn_export()">导出</button>
</body>
<script src="js/xlsx.extendscript.js"></script>
<script src="js/xlsx-style/xlsx.full.min.js"></script>
<script src="js/export.js"></script>
<script>
function btn_export() {
var table1 = document.querySelector("#table1");
var opt = {
rowIndex: 4
}; //开头空4行
var sheet = XLSX2.utils.table_to_sheet(table1, opt);
sheet["A1"] = {
t: "s",
v: '三鹿集团有限公司'
}; //给A1单元格赋值
sheet["A1"].s = {
font: {
name: '宋体',
sz: 24,
bold: true,
underline: true,
color: {
rgb: "FFFFAA00"
}
},
alignment: {
horizontal: "center",
vertical: "center",
wrap_text: true
},
fill: {
bgColor: {
rgb: 'ffff00'
}
}
};
//["!merges"]这个属性是专门用来进行单元格合并的
sheet["!merges"].push({ //如果不为空push 为空 = 赋值
//合并单元格 index都从0开始
s: { //s开始
c: 0, //开始列
r: 0 //开始行
},
e: { //e结束
c: 3, //结束列
r: 2 //结束行
}
});
sheet["A9"].s = { //样式
font: {
sz: 13,
bold: true,
color: {
rgb: "FFFFAA00"
}
},
alignment: {
horizontal: "center",
vertical: "center",
wrap_text: true
}
};
sheet["!cols"] = [{
wpx: 70
}, {
wpx: 70
}, {
wpx: 70
}, {
wpx: 70
}, {
wpx: 150
}, {
wpx: 120
}]; //单元格列宽
openDownloadDialog(sheet2blob(sheet), '下载.xlsx');
}
</script>
</html>