-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (44 loc) · 1.31 KB
/
script.js
File metadata and controls
54 lines (44 loc) · 1.31 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
// Code goes here
function export_table_to_excel(id, type, fn) {
var wb = XLSX.utils.table_to_book(document.getElementById(id), {sheet:"Sheet JS"});
var wbout = XLSX.write(wb, {bookType:type, bookSST:true, type: 'binary'});
var fname = fn || 'test.' + type;
try {
saveAs(new Blob([s2ab(wbout)],{type:"application/octet-stream"}), fname);
} catch(e) { if(typeof console != 'undefined') console.log(e, wbout); }
return wbout;
}
function s2ab(s) {
if(typeof ArrayBuffer !== 'undefined') {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
} else {
var buf = new Array(s.length);
for (var i=0; i!=s.length; ++i) buf[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
}
function doit(type, fn) { return export_table_to_excel('table', type || 'xlsx', fn); }
excelCell.s = {
fill: {
patternType: "none", // none / solid
fgColor: {rgb: "FF000000"},
bgColor: {rgb: "FFFFFFFF"}
},
font: {
name: 'Times New Roman',
sz: 16,
color: {rgb: "#FF000000"},
bold: false,
italic: false,
underline: false
},
border: {
top: {style: "thin", color: {auto: 1}},
right: {style: "thin", color: {auto: 1}},
bottom: {style: "thin", color: {auto: 1}},
left: {style: "thin", color: {auto: 1}}
}
};