-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathexample.js
140 lines (135 loc) · 5.23 KB
/
example.js
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
138
139
140
var XLSX = require('xlsx');
var Workbook = require('./workbook');
///credit http://daveaddey.com/?p=40
function JSDateToExcelDate(inDate) {
return 25569.0 + ((inDate.getTime() - (inDate.getTimezoneOffset() * 60 * 1000)) / (1000 * 60 * 60 * 24));
}
var workbook = new Workbook( )
.addRowsToSheet("Main", [
[ {
v: "This is a submerged cell",
s:{
border: {
left: {style: 'thick', color: {auto: 1}},
top: {style: 'thick', color: {auto: 1}},
bottom: {style: 'thick', color: {auto: 1}}
}
}
},
{
v: "Pirate ship",
s:{
border: {
top: {style: 'thick', color: {auto: 1}},
bottom: {style: 'thick', color: {auto: 1}}
}
}
},
{
v: "Sunken treasure",
s:{
border: {
right: {style: 'thick', color: {auto: 1}},
top: {style: 'thick', color: {auto: 1}},
bottom: {style: 'thick', color: {auto: 1}}
}
}
}
],
[
{"v": "Blank"},
{"v": "Red", "s": {fill: { fgColor: { rgb: "FFFF0000"}}}},
{"v": "Green", "s": {fill: { fgColor: { rgb: "FF00FF00"}}}},
{"v": "Blue", "s": {fill: { fgColor: { rgb: "FF0000FF"}}}}
],
[
{"v": "Default"},
{"v": "Arial", "s": {font: {name: "Arial", sz: 24, color: {rgb: "FFFF0000"}}}},
{"v": "Times New Roman", "s": {font: {name: "Times New Roman", sz: 16, bold: true, italic: true, underline: true, strike: true, outline: true, shadow:true, vertAlign: "superscript"}}},
{"v": "Courier New", "s": {font: {name: "Courier New", sz: 14}}}
],
[
{"v": "Normal"},
{"v": "Bold", "s": {font: {bold: true}, fill: { fgColor: { rgb: "FFFF0000"}}}},
{"v": "Italic", "s": {font: {italic: true}, fill: { fgColor: { rgb: "FF00FF00"}}}},
{"v": "Underline", "s": {underline: {bold: true}}},
{"v": "All", "s": {font: {bold: true ,italic: true, underline: true}}}
],
[
0.618033989,
{"v": 0.618033989},
{"v": 0.618033989, "t": "n"},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.00%"}},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.00%"}, fill: { fgColor: { rgb: "FFFFCC00"}}}
],
[
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0%"}},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.0%"}},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.00%"}},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.000%"}},
{"v": 0.618033989, "t": "n", "s": { "numFmt": "0.0000%"}},
{"v": 0, "t": "n", "s": { numFmt: "0.00%;\\(0.00%\\);\\-;@"}, fill: { fgColor: { rgb: "FFFFCC00"}}}
],
[
{v: (new Date()).toLocaleString()},
{v: (new Date()), t: 'd'},
{v: (new Date()), s: {numFmt: 'd-mmm-yy'}}
]
,
[
{v: "left", "s": { alignment: {horizontal: "left"}}},
{v: "left", "s": { alignment: {horizontal: "center"}}},
{v: "left", "s": { alignment: {horizontal: "right"}}}
],[
{v: "vertical", "s": { alignment: {vertical: "top"}}},
{v: "vertical", "s": { alignment: {vertical: "center"}}},
{v: "vertical", "s": { alignment: {vertical: "bottom"}}}
],[
{v: "indent", "s": { alignment: {indent: "1"}}},
{v: "indent", "s": { alignment: {indent: "2"}}},
{v: "indent", "s": { alignment: {indent: "3"}}}
],
[{
v: "In publishing and graphic design, lorem ipsum is a filler text commonly used to demonstrate the graphic elements of a document or visual presentation. ",
s: { alignment: { wrapText: 1, alignment: 'right', vertical: 'center', indent: 1}}
}
],
[
{v: 41684.35264774306, s: {numFmt: 'm/d/yy'}},
{v: 41684.35264774306, s: {numFmt: 'd-mmm-yy'}},
{v: 41684.35264774306, s: {numFmt: 'h:mm:ss AM/PM'}},
{v: new Date(), s: {numFmt: 'm/d/yy'}},
{v: 42065.02247239584, s: {numFmt: 'm/d/yy'}},
{v: new Date(), s: {numFmt: 'm/d/yy h:mm:ss AM/PM'}}
],
[
// {v: "Apple", s: {border: {top: { style: "thin"}}, left: { style: "thin"}, right: { style: "thin"}, bottom: { style: "thin"}}}
{
v: "Border test",
s: {
border: {
diagonalUp: false,
diagonalDown: true,
top: { style: "thick", color: {auto: 1}},
right: { style: "thick", color: {theme: "5"}},
bottom: { style: "thick", color: {theme: 5, tint: "-0.3"}},
left: { style: "thick", color: {rgb: "FFFFAA00"}},
diagonal: {style: "thick", color: {theme: 6}}
}
}
}
]
]).mergeCells("Main", {
"s": {"c": 0, "r": 0 },
"e": {"c": 2, "r": 0 }
})
.setColWidthChars('Main', 1,72)
.finalize();
//workbook.Sheets['Main']['!cols']=[{wch:24}]
var OUTFILE = '/tmp/wb.xlsx';
var OUTFILE1 = '/tmp/wb1.xlsx';
XLSX.writeFile(workbook, OUTFILE);
console.log("Results written to " + OUTFILE)
var workbook1 = XLSX.readFile(OUTFILE, {cellStyles: true, cellNF: true});
XLSX.writeFile(workbook1, OUTFILE1);
console.log("Results written to " + OUTFILE1)