Skip to content
This repository was archived by the owner on Apr 18, 2020. It is now read-only.

Commit 6ce7615

Browse files
authored
Merge pull request #15 from linways/#11
Added option to specify row height
2 parents 8dbc2ae + af4a398 commit 6ce7615

File tree

12 files changed

+59
-11
lines changed

12 files changed

+59
-11
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ Example:
148148
</table>
149149
```
150150

151+
# Row Height
152+
153+
Row Height can be set by specifying `data-height` in the `<tr>` tag.
154+
Example:
155+
156+
```html
157+
<tr data-height="42.5">
158+
<td>Cell 1</td>
159+
<td>Cell 2</td>
160+
</tr>
161+
```
162+
151163
# Release Changelog
152164

153165
## 1.0.0
@@ -166,3 +178,11 @@ Example:
166178
- String "true/false" will be accepted as Boolean
167179
- Changed border style values
168180
- Text rotation values changed
181+
182+
## 1.0.2
183+
184+
- Fixed bug in handling multiple columns merges in a sheet
185+
186+
## 1.0.3
187+
188+
- Option to specify row height

dist/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@
9393
<td data-exclude="true">Excluded Cell</td>
9494
<td>Included Cell</td>
9595
</tr>
96+
<tr data-height="42">
97+
<td>Row height 42</td>
98+
</tr>
9699
</tbody>
97100
</table>
98101

dist/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ var parent = module.bundle.parent;
198198
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
199199
var hostname = "" || location.hostname;
200200
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
201-
var ws = new WebSocket(protocol + '://' + hostname + ':' + "52850" + '/');
201+
var ws = new WebSocket(protocol + '://' + hostname + ':' + "49818" + '/');
202202

203203
ws.onmessage = function (event) {
204204
var data = JSON.parse(event.data);

dist/tableToExcel.517b1af9.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,22 @@ var TTEParser = function () {
141141

142142
for (_r = 0; _r < rows.length; ++_r) {
143143
var row = rows[_r];
144+
r = _r + 1; // Actual excel row number
145+
146+
c = 1; // Actual excel col number
144147

145148
if (row.getAttribute("data-exclude") === "true") {
146149
rows.splice(_r, 1);
147150
_r--;
148151
continue;
149152
}
150153

151-
var tds = _toConsumableArray(row.children);
154+
if (row.getAttribute("data-height")) {
155+
var exRow = ws.getRow(r);
156+
exRow.height = parseFloat(row.getAttribute("data-height"));
157+
}
152158

153-
r = _r + 1;
154-
c = 1;
159+
var tds = _toConsumableArray(row.children);
155160

156161
for (_c = 0; _c < tds.length; ++_c) {
157162
var td = tds[_c];
@@ -44629,7 +44634,7 @@ var parent = module.bundle.parent;
4462944634
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
4463044635
var hostname = "" || location.hostname;
4463144636
var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
44632-
var ws = new WebSocket(protocol + '://' + hostname + ':' + "52850" + '/');
44637+
var ws = new WebSocket(protocol + '://' + hostname + ':' + "49818" + '/');
4463344638

4463444639
ws.onmessage = function (event) {
4463544640
var data = JSON.parse(event.data);

dist/tableToExcel.517b1af9.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tableToExcel.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tableToExcel.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linways/table-to-excel",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "Javascript library to create 'valid' excel file from html table with styles",
55
"main": "./dist/tableToExcel.js",
66
"repository": {

sample/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@
140140
<td data-exclude="true">Excluded Cell</td>
141141
<td>Included Cell</td>
142142
</tr>
143+
<tr data-height="42">
144+
<td>Row height 42</td>
145+
</tr>
143146
</tbody>
144147
</table>
145148

src/parser.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,19 @@ const TTEParser = (function() {
1717
let merges = [];
1818
for (_r = 0; _r < rows.length; ++_r) {
1919
let row = rows[_r];
20+
r = _r + 1; // Actual excel row number
21+
c = 1; // Actual excel col number
2022
if (row.getAttribute("data-exclude") === "true") {
2123
rows.splice(_r, 1);
2224
_r--;
2325
continue;
2426
}
27+
if (row.getAttribute("data-height")) {
28+
let exRow = ws.getRow(r);
29+
exRow.height = parseFloat(row.getAttribute("data-height"));
30+
}
31+
2532
let tds = [...row.children];
26-
r = _r + 1;
27-
c = 1;
2833
for (_c = 0; _c < tds.length; ++_c) {
2934
let td = tds[_c];
3035
if (td.getAttribute("data-exclude") === "true") {

0 commit comments

Comments
 (0)