-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
215 lines (212 loc) · 8.44 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>typexlsx</title>
<link rel="icon" type="image/svg+xml" href="./assets/favicon.svg" />
<link
rel="alternate icon"
type="image/png"
href="./assets/favicon32x32.png"
/>
</head>
<body>
<div id="app">
<div class="row" style="align-items: center">
<img
src="./assets/favicon64x64.png"
width="64"
height="64"
alt="logo"
/>
<div>
<h1>typexlsx</h1>
<h5>Write *.xlsx files in a browser or Node.js</h5>
</div>
</div>
<div class="row">
<!--export data sheet-->
<div class="box">
<h2>export Data Sheet to xlsx</h2>
<div class="content">
<pre><code style="flex-grow: 1;" class="language-typescript">import { saveAs } from 'file-saver';
import generateXlsx from 'typexlsx';
const sheet: Sheet = {
name: 'TestFile',
rows: [
[
{
value: 'A',
span: 2,
border: { end: { color: '#000000', style: 'thick' } },
},
{ value: 'B' },
{
value: 'C',
font: { family: 'Times New Roman', color: '#00FF00' },
fill: '#880077',
},
],
[{ value: 1 }, { value: 2 }, { value: 3 }],
[{ value: 'test', span: 3, rowSpan: 2 }],
],
};
generateXlsx(TEST_FILE)
.then((blob) => saveAs(blob, 'Workbook.xlsx'))
.catch((err) => console.error(err));</code></pre>
</div>
<button id="btn:download">Download XLSX</button>
</div>
<!--export html table-->
<div class="box">
<h2>export HTML Table to xlsx</h2>
<div class="content">
<pre><code class="language-css">table {
border-collapse: collapse;
width: 100%;
text-align: center;
}
table > thead > tr > th {
background-color: #c5d9f1;
}
.even {
background-color: #d8e4bc;
}
.odd {
background-color: #ebf1de;
}
table > tfoot > tr {
background-color: #d99594;
}
table > thead > tr > th,
table > tbody > tr > td,
table > tfoot > tr > td {
color: black;
padding: 4px;
border: 2px solid black;
}</code></pre>
<br />
<pre><code class="language-typescript">import { saveAs } from 'file-saver';
import generateXlsx, { htmlTableToSheet } from 'typexlsx';
generateXlsx(htmlTableToSheet(document.getElementById('table')))
.then((blob) => saveAs(blob, 'Workbook.xlsx'))
.catch((err) => console.error(err));</code></pre>
<br />
<table id="table">
<thead>
<tr>
<th>Anlagen Nr.</th>
<th>Wechselrichter</th>
<th>Dachausrichtung</th>
<th>Dachneigung</th>
<th>Strings</th>
<th>Module pro String</th>
<th>Module pro WR</th>
<th>kWp pro WR</th>
<th>Kunde</th>
</tr>
</thead>
<tbody>
<tr class="even">
<td rowspan="6">3</td>
<td rowspan="6">Huawei SUN2000 60KTL-M0</td>
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>18</td>
<td rowspan="6">210</td>
<td rowspan="6">67,200 kWp</td>
<td rowspan="6">Max Mustermann</td>
</tr>
<tr class="even">
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>18</td>
</tr>
<tr class="even">
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>18</td>
</tr>
<tr class="even">
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>17</td>
</tr>
<tr class="even">
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>17</td>
</tr>
<tr class="even">
<td>90°</td>
<td>12°</td>
<td>2</td>
<td>17</td>
</tr>
<tr class="odd">
<td rowspan="6">6</td>
<td rowspan="6">Huawei SUN2000 60KTL-M0</td>
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>16</td>
<td rowspan="6">172</td>
<td rowspan="6">66,666 kWp</td>
<td rowspan="6">Max Mustermann</td>
</tr>
<tr class="odd">
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>14</td>
</tr>
<tr class="odd">
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>14</td>
</tr>
<tr class="odd">
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>14</td>
</tr>
<tr class="odd">
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>14</td>
</tr>
<tr class="odd">
<td>0°</td>
<td>12°</td>
<td>2</td>
<td>14</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="6" style="text-align: right">
Summe:
</th>
<th>382</th>
<th>69,420 kWp</th>
<th></th>
</tr>
</tfoot>
</table>
</div>
<button id="btn:export">Export HTML Table</button>
</div>
</div>
</div>
<script type="module" src="./docs/main.ts"></script>
</body>
</html>