@cj-tech-master/excelts 5.1.9 → 5.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/modules/excel/cell.js +15 -5
- package/dist/browser/modules/excel/row.js +3 -2
- package/dist/browser/modules/excel/worksheet.js +6 -6
- package/dist/cjs/modules/excel/cell.js +15 -5
- package/dist/cjs/modules/excel/row.js +3 -2
- package/dist/cjs/modules/excel/worksheet.js +6 -6
- package/dist/esm/modules/excel/cell.js +15 -5
- package/dist/esm/modules/excel/row.js +3 -2
- package/dist/esm/modules/excel/worksheet.js +6 -6
- package/dist/iife/excelts.iife.js +54 -53
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +24 -24
- package/package.json +1 -1
|
@@ -3,6 +3,11 @@ import { Enums } from "./enums.js";
|
|
|
3
3
|
import { Note } from "./note.js";
|
|
4
4
|
import { escapeHtml } from "./utils/under-dash.js";
|
|
5
5
|
import { slideFormula } from "./utils/shared-formula.js";
|
|
6
|
+
// Returns true if the value is a non-empty object (has at least one own key),
|
|
7
|
+
// or any truthy non-object value. Returns false for undefined, null, false, 0,
|
|
8
|
+
// empty string, and empty objects `{}`. This is used to prevent an empty `{}`
|
|
9
|
+
// style property on a row from shadowing a real style property on a column.
|
|
10
|
+
const hasOwnKeys = (v) => !!v && (typeof v !== "object" || Object.keys(v).length > 0);
|
|
6
11
|
// Cell requirements
|
|
7
12
|
// Operate inside a worksheet
|
|
8
13
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -78,23 +83,28 @@ class Cell {
|
|
|
78
83
|
if (numFmt) {
|
|
79
84
|
style.numFmt = numFmt;
|
|
80
85
|
}
|
|
81
|
-
const font = (rowStyle && rowStyle.font)
|
|
86
|
+
const font = (rowStyle && hasOwnKeys(rowStyle.font) && rowStyle.font) ||
|
|
87
|
+
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
82
88
|
if (font) {
|
|
83
89
|
style.font = font;
|
|
84
90
|
}
|
|
85
|
-
const alignment = (rowStyle && rowStyle.alignment)
|
|
91
|
+
const alignment = (rowStyle && hasOwnKeys(rowStyle.alignment) && rowStyle.alignment) ||
|
|
92
|
+
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
86
93
|
if (alignment) {
|
|
87
94
|
style.alignment = alignment;
|
|
88
95
|
}
|
|
89
|
-
const border = (rowStyle && rowStyle.border)
|
|
96
|
+
const border = (rowStyle && hasOwnKeys(rowStyle.border) && rowStyle.border) ||
|
|
97
|
+
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
90
98
|
if (border) {
|
|
91
99
|
style.border = border;
|
|
92
100
|
}
|
|
93
|
-
const fill = (rowStyle && rowStyle.fill)
|
|
101
|
+
const fill = (rowStyle && hasOwnKeys(rowStyle.fill) && rowStyle.fill) ||
|
|
102
|
+
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
94
103
|
if (fill) {
|
|
95
104
|
style.fill = fill;
|
|
96
105
|
}
|
|
97
|
-
const protection = (rowStyle && rowStyle.protection)
|
|
106
|
+
const protection = (rowStyle && hasOwnKeys(rowStyle.protection) && rowStyle.protection) ||
|
|
107
|
+
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
98
108
|
if (protection) {
|
|
99
109
|
style.protection = protection;
|
|
100
110
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Enums } from "./enums.js";
|
|
2
2
|
import { colCache } from "./utils/col-cache.js";
|
|
3
3
|
import { Cell } from "./cell.js";
|
|
4
|
+
import { copyStyle } from "./utils/copy-style.js";
|
|
4
5
|
class Row {
|
|
5
6
|
constructor(worksheet, number) {
|
|
6
7
|
this._worksheet = worksheet;
|
|
@@ -95,7 +96,7 @@ class Row {
|
|
|
95
96
|
if (cSrc) {
|
|
96
97
|
cDst = this.getCell(i);
|
|
97
98
|
cDst.value = cSrc.value;
|
|
98
|
-
cDst.style = cSrc.style;
|
|
99
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
99
100
|
cDst.comment = cSrc.comment;
|
|
100
101
|
}
|
|
101
102
|
else if (cDst) {
|
|
@@ -112,7 +113,7 @@ class Row {
|
|
|
112
113
|
if (cSrc) {
|
|
113
114
|
cDst = this.getCell(i + nExpand);
|
|
114
115
|
cDst.value = cSrc.value;
|
|
115
|
-
cDst.style = cSrc.style;
|
|
116
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
116
117
|
cDst.comment = cSrc.comment;
|
|
117
118
|
}
|
|
118
119
|
else {
|
|
@@ -508,10 +508,10 @@ class Worksheet {
|
|
|
508
508
|
// now copy styles...
|
|
509
509
|
for (let i = 0; i < count; i++) {
|
|
510
510
|
const rDst = this._rows[rowNum + i];
|
|
511
|
-
rDst.style = rSrc.style;
|
|
511
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
512
512
|
rDst.height = rSrc.height;
|
|
513
513
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
514
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
514
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
// Duplicate single-row merges from source row into each new row
|
|
@@ -599,10 +599,10 @@ class Worksheet {
|
|
|
599
599
|
if (rSrc) {
|
|
600
600
|
const rDst = this.getRow(i + nExpand);
|
|
601
601
|
rDst.values = rSrc.values;
|
|
602
|
-
rDst.style = rSrc.style;
|
|
602
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
603
603
|
rDst.height = rSrc.height;
|
|
604
604
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
605
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
605
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
606
606
|
});
|
|
607
607
|
this._rows[i - 1] = undefined;
|
|
608
608
|
}
|
|
@@ -618,10 +618,10 @@ class Worksheet {
|
|
|
618
618
|
if (rSrc) {
|
|
619
619
|
const rDst = this.getRow(i + nExpand);
|
|
620
620
|
rDst.values = rSrc.values;
|
|
621
|
-
rDst.style = rSrc.style;
|
|
621
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
622
622
|
rDst.height = rSrc.height;
|
|
623
623
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
624
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
624
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
627
|
else {
|
|
@@ -6,6 +6,11 @@ const enums_1 = require("./enums.js");
|
|
|
6
6
|
const note_1 = require("./note.js");
|
|
7
7
|
const under_dash_1 = require("./utils/under-dash.js");
|
|
8
8
|
const shared_formula_1 = require("./utils/shared-formula.js");
|
|
9
|
+
// Returns true if the value is a non-empty object (has at least one own key),
|
|
10
|
+
// or any truthy non-object value. Returns false for undefined, null, false, 0,
|
|
11
|
+
// empty string, and empty objects `{}`. This is used to prevent an empty `{}`
|
|
12
|
+
// style property on a row from shadowing a real style property on a column.
|
|
13
|
+
const hasOwnKeys = (v) => !!v && (typeof v !== "object" || Object.keys(v).length > 0);
|
|
9
14
|
// Cell requirements
|
|
10
15
|
// Operate inside a worksheet
|
|
11
16
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -81,23 +86,28 @@ class Cell {
|
|
|
81
86
|
if (numFmt) {
|
|
82
87
|
style.numFmt = numFmt;
|
|
83
88
|
}
|
|
84
|
-
const font = (rowStyle && rowStyle.font)
|
|
89
|
+
const font = (rowStyle && hasOwnKeys(rowStyle.font) && rowStyle.font) ||
|
|
90
|
+
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
85
91
|
if (font) {
|
|
86
92
|
style.font = font;
|
|
87
93
|
}
|
|
88
|
-
const alignment = (rowStyle && rowStyle.alignment)
|
|
94
|
+
const alignment = (rowStyle && hasOwnKeys(rowStyle.alignment) && rowStyle.alignment) ||
|
|
95
|
+
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
89
96
|
if (alignment) {
|
|
90
97
|
style.alignment = alignment;
|
|
91
98
|
}
|
|
92
|
-
const border = (rowStyle && rowStyle.border)
|
|
99
|
+
const border = (rowStyle && hasOwnKeys(rowStyle.border) && rowStyle.border) ||
|
|
100
|
+
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
93
101
|
if (border) {
|
|
94
102
|
style.border = border;
|
|
95
103
|
}
|
|
96
|
-
const fill = (rowStyle && rowStyle.fill)
|
|
104
|
+
const fill = (rowStyle && hasOwnKeys(rowStyle.fill) && rowStyle.fill) ||
|
|
105
|
+
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
97
106
|
if (fill) {
|
|
98
107
|
style.fill = fill;
|
|
99
108
|
}
|
|
100
|
-
const protection = (rowStyle && rowStyle.protection)
|
|
109
|
+
const protection = (rowStyle && hasOwnKeys(rowStyle.protection) && rowStyle.protection) ||
|
|
110
|
+
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
101
111
|
if (protection) {
|
|
102
112
|
style.protection = protection;
|
|
103
113
|
}
|
|
@@ -4,6 +4,7 @@ exports.Row = void 0;
|
|
|
4
4
|
const enums_1 = require("./enums.js");
|
|
5
5
|
const col_cache_1 = require("./utils/col-cache.js");
|
|
6
6
|
const cell_1 = require("./cell.js");
|
|
7
|
+
const copy_style_1 = require("./utils/copy-style.js");
|
|
7
8
|
class Row {
|
|
8
9
|
constructor(worksheet, number) {
|
|
9
10
|
this._worksheet = worksheet;
|
|
@@ -98,7 +99,7 @@ class Row {
|
|
|
98
99
|
if (cSrc) {
|
|
99
100
|
cDst = this.getCell(i);
|
|
100
101
|
cDst.value = cSrc.value;
|
|
101
|
-
cDst.style = cSrc.style;
|
|
102
|
+
cDst.style = (0, copy_style_1.copyStyle)(cSrc.style) ?? {};
|
|
102
103
|
cDst.comment = cSrc.comment;
|
|
103
104
|
}
|
|
104
105
|
else if (cDst) {
|
|
@@ -115,7 +116,7 @@ class Row {
|
|
|
115
116
|
if (cSrc) {
|
|
116
117
|
cDst = this.getCell(i + nExpand);
|
|
117
118
|
cDst.value = cSrc.value;
|
|
118
|
-
cDst.style = cSrc.style;
|
|
119
|
+
cDst.style = (0, copy_style_1.copyStyle)(cSrc.style) ?? {};
|
|
119
120
|
cDst.comment = cSrc.comment;
|
|
120
121
|
}
|
|
121
122
|
else {
|
|
@@ -511,10 +511,10 @@ class Worksheet {
|
|
|
511
511
|
// now copy styles...
|
|
512
512
|
for (let i = 0; i < count; i++) {
|
|
513
513
|
const rDst = this._rows[rowNum + i];
|
|
514
|
-
rDst.style = rSrc.style;
|
|
514
|
+
rDst.style = (0, copy_style_1.copyStyle)(rSrc.style) ?? {};
|
|
515
515
|
rDst.height = rSrc.height;
|
|
516
516
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
517
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
517
|
+
rDst.getCell(colNumber).style = (0, copy_style_1.copyStyle)(cell.style) ?? {};
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
520
|
// Duplicate single-row merges from source row into each new row
|
|
@@ -602,10 +602,10 @@ class Worksheet {
|
|
|
602
602
|
if (rSrc) {
|
|
603
603
|
const rDst = this.getRow(i + nExpand);
|
|
604
604
|
rDst.values = rSrc.values;
|
|
605
|
-
rDst.style = rSrc.style;
|
|
605
|
+
rDst.style = (0, copy_style_1.copyStyle)(rSrc.style) ?? {};
|
|
606
606
|
rDst.height = rSrc.height;
|
|
607
607
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
608
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
608
|
+
rDst.getCell(colNumber).style = (0, copy_style_1.copyStyle)(cell.style) ?? {};
|
|
609
609
|
});
|
|
610
610
|
this._rows[i - 1] = undefined;
|
|
611
611
|
}
|
|
@@ -621,10 +621,10 @@ class Worksheet {
|
|
|
621
621
|
if (rSrc) {
|
|
622
622
|
const rDst = this.getRow(i + nExpand);
|
|
623
623
|
rDst.values = rSrc.values;
|
|
624
|
-
rDst.style = rSrc.style;
|
|
624
|
+
rDst.style = (0, copy_style_1.copyStyle)(rSrc.style) ?? {};
|
|
625
625
|
rDst.height = rSrc.height;
|
|
626
626
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
627
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
627
|
+
rDst.getCell(colNumber).style = (0, copy_style_1.copyStyle)(cell.style) ?? {};
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
else {
|
|
@@ -3,6 +3,11 @@ import { Enums } from "./enums.js";
|
|
|
3
3
|
import { Note } from "./note.js";
|
|
4
4
|
import { escapeHtml } from "./utils/under-dash.js";
|
|
5
5
|
import { slideFormula } from "./utils/shared-formula.js";
|
|
6
|
+
// Returns true if the value is a non-empty object (has at least one own key),
|
|
7
|
+
// or any truthy non-object value. Returns false for undefined, null, false, 0,
|
|
8
|
+
// empty string, and empty objects `{}`. This is used to prevent an empty `{}`
|
|
9
|
+
// style property on a row from shadowing a real style property on a column.
|
|
10
|
+
const hasOwnKeys = (v) => !!v && (typeof v !== "object" || Object.keys(v).length > 0);
|
|
6
11
|
// Cell requirements
|
|
7
12
|
// Operate inside a worksheet
|
|
8
13
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -78,23 +83,28 @@ class Cell {
|
|
|
78
83
|
if (numFmt) {
|
|
79
84
|
style.numFmt = numFmt;
|
|
80
85
|
}
|
|
81
|
-
const font = (rowStyle && rowStyle.font)
|
|
86
|
+
const font = (rowStyle && hasOwnKeys(rowStyle.font) && rowStyle.font) ||
|
|
87
|
+
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
82
88
|
if (font) {
|
|
83
89
|
style.font = font;
|
|
84
90
|
}
|
|
85
|
-
const alignment = (rowStyle && rowStyle.alignment)
|
|
91
|
+
const alignment = (rowStyle && hasOwnKeys(rowStyle.alignment) && rowStyle.alignment) ||
|
|
92
|
+
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
86
93
|
if (alignment) {
|
|
87
94
|
style.alignment = alignment;
|
|
88
95
|
}
|
|
89
|
-
const border = (rowStyle && rowStyle.border)
|
|
96
|
+
const border = (rowStyle && hasOwnKeys(rowStyle.border) && rowStyle.border) ||
|
|
97
|
+
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
90
98
|
if (border) {
|
|
91
99
|
style.border = border;
|
|
92
100
|
}
|
|
93
|
-
const fill = (rowStyle && rowStyle.fill)
|
|
101
|
+
const fill = (rowStyle && hasOwnKeys(rowStyle.fill) && rowStyle.fill) ||
|
|
102
|
+
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
94
103
|
if (fill) {
|
|
95
104
|
style.fill = fill;
|
|
96
105
|
}
|
|
97
|
-
const protection = (rowStyle && rowStyle.protection)
|
|
106
|
+
const protection = (rowStyle && hasOwnKeys(rowStyle.protection) && rowStyle.protection) ||
|
|
107
|
+
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
98
108
|
if (protection) {
|
|
99
109
|
style.protection = protection;
|
|
100
110
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Enums } from "./enums.js";
|
|
2
2
|
import { colCache } from "./utils/col-cache.js";
|
|
3
3
|
import { Cell } from "./cell.js";
|
|
4
|
+
import { copyStyle } from "./utils/copy-style.js";
|
|
4
5
|
class Row {
|
|
5
6
|
constructor(worksheet, number) {
|
|
6
7
|
this._worksheet = worksheet;
|
|
@@ -95,7 +96,7 @@ class Row {
|
|
|
95
96
|
if (cSrc) {
|
|
96
97
|
cDst = this.getCell(i);
|
|
97
98
|
cDst.value = cSrc.value;
|
|
98
|
-
cDst.style = cSrc.style;
|
|
99
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
99
100
|
cDst.comment = cSrc.comment;
|
|
100
101
|
}
|
|
101
102
|
else if (cDst) {
|
|
@@ -112,7 +113,7 @@ class Row {
|
|
|
112
113
|
if (cSrc) {
|
|
113
114
|
cDst = this.getCell(i + nExpand);
|
|
114
115
|
cDst.value = cSrc.value;
|
|
115
|
-
cDst.style = cSrc.style;
|
|
116
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
116
117
|
cDst.comment = cSrc.comment;
|
|
117
118
|
}
|
|
118
119
|
else {
|
|
@@ -508,10 +508,10 @@ class Worksheet {
|
|
|
508
508
|
// now copy styles...
|
|
509
509
|
for (let i = 0; i < count; i++) {
|
|
510
510
|
const rDst = this._rows[rowNum + i];
|
|
511
|
-
rDst.style = rSrc.style;
|
|
511
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
512
512
|
rDst.height = rSrc.height;
|
|
513
513
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
514
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
514
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
// Duplicate single-row merges from source row into each new row
|
|
@@ -599,10 +599,10 @@ class Worksheet {
|
|
|
599
599
|
if (rSrc) {
|
|
600
600
|
const rDst = this.getRow(i + nExpand);
|
|
601
601
|
rDst.values = rSrc.values;
|
|
602
|
-
rDst.style = rSrc.style;
|
|
602
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
603
603
|
rDst.height = rSrc.height;
|
|
604
604
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
605
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
605
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
606
606
|
});
|
|
607
607
|
this._rows[i - 1] = undefined;
|
|
608
608
|
}
|
|
@@ -618,10 +618,10 @@ class Worksheet {
|
|
|
618
618
|
if (rSrc) {
|
|
619
619
|
const rDst = this.getRow(i + nExpand);
|
|
620
620
|
rDst.values = rSrc.values;
|
|
621
|
-
rDst.style = rSrc.style;
|
|
621
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
622
622
|
rDst.height = rSrc.height;
|
|
623
623
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
624
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
624
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
627
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v5.1.
|
|
2
|
+
* @cj-tech-master/excelts v5.1.10
|
|
3
3
|
* TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
|
|
4
4
|
* (c) 2026 cjnoname
|
|
5
5
|
* Released under the MIT License
|
|
@@ -651,6 +651,7 @@ var ExcelTS = (function(exports) {
|
|
|
651
651
|
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region src/modules/excel/cell.ts
|
|
654
|
+
const hasOwnKeys = (v) => !!v && (typeof v !== "object" || Object.keys(v).length > 0);
|
|
654
655
|
var Cell = class Cell {
|
|
655
656
|
static {
|
|
656
657
|
this.Types = Enums.ValueType;
|
|
@@ -717,15 +718,15 @@ var ExcelTS = (function(exports) {
|
|
|
717
718
|
_mergeStyle(rowStyle, colStyle, style) {
|
|
718
719
|
const numFmt = rowStyle && rowStyle.numFmt || colStyle && colStyle.numFmt;
|
|
719
720
|
if (numFmt) style.numFmt = numFmt;
|
|
720
|
-
const font = rowStyle && rowStyle.font || colStyle && colStyle.font;
|
|
721
|
+
const font = rowStyle && hasOwnKeys(rowStyle.font) && rowStyle.font || colStyle && hasOwnKeys(colStyle.font) && colStyle.font;
|
|
721
722
|
if (font) style.font = font;
|
|
722
|
-
const alignment = rowStyle && rowStyle.alignment || colStyle && colStyle.alignment;
|
|
723
|
+
const alignment = rowStyle && hasOwnKeys(rowStyle.alignment) && rowStyle.alignment || colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment;
|
|
723
724
|
if (alignment) style.alignment = alignment;
|
|
724
|
-
const border = rowStyle && rowStyle.border || colStyle && colStyle.border;
|
|
725
|
+
const border = rowStyle && hasOwnKeys(rowStyle.border) && rowStyle.border || colStyle && hasOwnKeys(colStyle.border) && colStyle.border;
|
|
725
726
|
if (border) style.border = border;
|
|
726
|
-
const fill = rowStyle && rowStyle.fill || colStyle && colStyle.fill;
|
|
727
|
+
const fill = rowStyle && hasOwnKeys(rowStyle.fill) && rowStyle.fill || colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill;
|
|
727
728
|
if (fill) style.fill = fill;
|
|
728
|
-
const protection = rowStyle && rowStyle.protection || colStyle && colStyle.protection;
|
|
729
|
+
const protection = rowStyle && hasOwnKeys(rowStyle.protection) && rowStyle.protection || colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection;
|
|
729
730
|
if (protection) style.protection = protection;
|
|
730
731
|
return style;
|
|
731
732
|
}
|
|
@@ -1523,6 +1524,45 @@ var ExcelTS = (function(exports) {
|
|
|
1523
1524
|
}
|
|
1524
1525
|
};
|
|
1525
1526
|
|
|
1527
|
+
//#endregion
|
|
1528
|
+
//#region src/modules/excel/utils/copy-style.ts
|
|
1529
|
+
const oneDepthCopy = (obj, nestKeys) => ({
|
|
1530
|
+
...obj,
|
|
1531
|
+
...nestKeys.reduce((memo, key) => {
|
|
1532
|
+
if (obj[key]) memo[key] = { ...obj[key] };
|
|
1533
|
+
return memo;
|
|
1534
|
+
}, {})
|
|
1535
|
+
});
|
|
1536
|
+
const setIfExists = (src, dst, key, nestKeys = []) => {
|
|
1537
|
+
if (src[key]) dst[key] = oneDepthCopy(src[key], nestKeys);
|
|
1538
|
+
};
|
|
1539
|
+
const isEmptyObj = (obj) => Object.keys(obj).length === 0;
|
|
1540
|
+
const copyStyle = (style) => {
|
|
1541
|
+
if (!style) return style;
|
|
1542
|
+
if (isEmptyObj(style)) return {};
|
|
1543
|
+
const copied = { ...style };
|
|
1544
|
+
setIfExists(style, copied, "font", ["color"]);
|
|
1545
|
+
setIfExists(style, copied, "alignment");
|
|
1546
|
+
setIfExists(style, copied, "protection");
|
|
1547
|
+
if (style.border) {
|
|
1548
|
+
setIfExists(style, copied, "border");
|
|
1549
|
+
setIfExists(style.border, copied.border, "top", ["color"]);
|
|
1550
|
+
setIfExists(style.border, copied.border, "left", ["color"]);
|
|
1551
|
+
setIfExists(style.border, copied.border, "bottom", ["color"]);
|
|
1552
|
+
setIfExists(style.border, copied.border, "right", ["color"]);
|
|
1553
|
+
setIfExists(style.border, copied.border, "diagonal", ["color"]);
|
|
1554
|
+
}
|
|
1555
|
+
if (style.fill) {
|
|
1556
|
+
setIfExists(style, copied, "fill", [
|
|
1557
|
+
"fgColor",
|
|
1558
|
+
"bgColor",
|
|
1559
|
+
"center"
|
|
1560
|
+
]);
|
|
1561
|
+
if (style.fill.stops) copied.fill.stops = style.fill.stops.map((s) => oneDepthCopy(s, ["color"]));
|
|
1562
|
+
}
|
|
1563
|
+
return copied;
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1526
1566
|
//#endregion
|
|
1527
1567
|
//#region src/modules/excel/row.ts
|
|
1528
1568
|
var Row = class {
|
|
@@ -1607,7 +1647,7 @@ var ExcelTS = (function(exports) {
|
|
|
1607
1647
|
if (cSrc) {
|
|
1608
1648
|
cDst = this.getCell(i);
|
|
1609
1649
|
cDst.value = cSrc.value;
|
|
1610
|
-
cDst.style = cSrc.style;
|
|
1650
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
1611
1651
|
cDst.comment = cSrc.comment;
|
|
1612
1652
|
} else if (cDst) {
|
|
1613
1653
|
cDst.value = null;
|
|
@@ -1620,7 +1660,7 @@ var ExcelTS = (function(exports) {
|
|
|
1620
1660
|
if (cSrc) {
|
|
1621
1661
|
cDst = this.getCell(i + nExpand);
|
|
1622
1662
|
cDst.value = cSrc.value;
|
|
1623
|
-
cDst.style = cSrc.style;
|
|
1663
|
+
cDst.style = copyStyle(cSrc.style) ?? {};
|
|
1624
1664
|
cDst.comment = cSrc.comment;
|
|
1625
1665
|
} else this._cells[i + nExpand - 1] = void 0;
|
|
1626
1666
|
}
|
|
@@ -5717,45 +5757,6 @@ var ExcelTS = (function(exports) {
|
|
|
5717
5757
|
return result;
|
|
5718
5758
|
}
|
|
5719
5759
|
|
|
5720
|
-
//#endregion
|
|
5721
|
-
//#region src/modules/excel/utils/copy-style.ts
|
|
5722
|
-
const oneDepthCopy = (obj, nestKeys) => ({
|
|
5723
|
-
...obj,
|
|
5724
|
-
...nestKeys.reduce((memo, key) => {
|
|
5725
|
-
if (obj[key]) memo[key] = { ...obj[key] };
|
|
5726
|
-
return memo;
|
|
5727
|
-
}, {})
|
|
5728
|
-
});
|
|
5729
|
-
const setIfExists = (src, dst, key, nestKeys = []) => {
|
|
5730
|
-
if (src[key]) dst[key] = oneDepthCopy(src[key], nestKeys);
|
|
5731
|
-
};
|
|
5732
|
-
const isEmptyObj = (obj) => Object.keys(obj).length === 0;
|
|
5733
|
-
const copyStyle = (style) => {
|
|
5734
|
-
if (!style) return style;
|
|
5735
|
-
if (isEmptyObj(style)) return {};
|
|
5736
|
-
const copied = { ...style };
|
|
5737
|
-
setIfExists(style, copied, "font", ["color"]);
|
|
5738
|
-
setIfExists(style, copied, "alignment");
|
|
5739
|
-
setIfExists(style, copied, "protection");
|
|
5740
|
-
if (style.border) {
|
|
5741
|
-
setIfExists(style, copied, "border");
|
|
5742
|
-
setIfExists(style.border, copied.border, "top", ["color"]);
|
|
5743
|
-
setIfExists(style.border, copied.border, "left", ["color"]);
|
|
5744
|
-
setIfExists(style.border, copied.border, "bottom", ["color"]);
|
|
5745
|
-
setIfExists(style.border, copied.border, "right", ["color"]);
|
|
5746
|
-
setIfExists(style.border, copied.border, "diagonal", ["color"]);
|
|
5747
|
-
}
|
|
5748
|
-
if (style.fill) {
|
|
5749
|
-
setIfExists(style, copied, "fill", [
|
|
5750
|
-
"fgColor",
|
|
5751
|
-
"bgColor",
|
|
5752
|
-
"center"
|
|
5753
|
-
]);
|
|
5754
|
-
if (style.fill.stops) copied.fill.stops = style.fill.stops.map((s) => oneDepthCopy(s, ["color"]));
|
|
5755
|
-
}
|
|
5756
|
-
return copied;
|
|
5757
|
-
};
|
|
5758
|
-
|
|
5759
5760
|
//#endregion
|
|
5760
5761
|
//#region src/modules/excel/worksheet.ts
|
|
5761
5762
|
var Worksheet = class {
|
|
@@ -6113,10 +6114,10 @@ var ExcelTS = (function(exports) {
|
|
|
6113
6114
|
this.spliceRows(rowNum + 1, insert ? 0 : count, ...inserts);
|
|
6114
6115
|
for (let i = 0; i < count; i++) {
|
|
6115
6116
|
const rDst = this._rows[rowNum + i];
|
|
6116
|
-
rDst.style = rSrc.style;
|
|
6117
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
6117
6118
|
rDst.height = rSrc.height;
|
|
6118
6119
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6119
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
6120
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
6120
6121
|
});
|
|
6121
6122
|
}
|
|
6122
6123
|
if (srcMerges.length > 0) for (let i = 0; i < count; i++) {
|
|
@@ -6176,10 +6177,10 @@ var ExcelTS = (function(exports) {
|
|
|
6176
6177
|
if (rSrc) {
|
|
6177
6178
|
const rDst = this.getRow(i + nExpand);
|
|
6178
6179
|
rDst.values = rSrc.values;
|
|
6179
|
-
rDst.style = rSrc.style;
|
|
6180
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
6180
6181
|
rDst.height = rSrc.height;
|
|
6181
6182
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6182
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
6183
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
6183
6184
|
});
|
|
6184
6185
|
this._rows[i - 1] = void 0;
|
|
6185
6186
|
} else this._rows[i + nExpand - 1] = void 0;
|
|
@@ -6189,10 +6190,10 @@ var ExcelTS = (function(exports) {
|
|
|
6189
6190
|
if (rSrc) {
|
|
6190
6191
|
const rDst = this.getRow(i + nExpand);
|
|
6191
6192
|
rDst.values = rSrc.values;
|
|
6192
|
-
rDst.style = rSrc.style;
|
|
6193
|
+
rDst.style = copyStyle(rSrc.style) ?? {};
|
|
6193
6194
|
rDst.height = rSrc.height;
|
|
6194
6195
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6195
|
-
rDst.getCell(colNumber).style = cell.style;
|
|
6196
|
+
rDst.getCell(colNumber).style = copyStyle(cell.style) ?? {};
|
|
6196
6197
|
});
|
|
6197
6198
|
} else this._rows[i + nExpand - 1] = void 0;
|
|
6198
6199
|
}
|