@cj-tech-master/excelts 5.1.9-canary.20260305174846.d717c19 → 5.1.9
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 +5 -15
- package/dist/browser/modules/excel/row.js +2 -3
- package/dist/browser/modules/excel/worksheet.js +6 -6
- package/dist/cjs/modules/excel/cell.js +5 -15
- package/dist/cjs/modules/excel/row.js +2 -3
- package/dist/cjs/modules/excel/worksheet.js +6 -6
- package/dist/esm/modules/excel/cell.js +5 -15
- package/dist/esm/modules/excel/row.js +2 -3
- package/dist/esm/modules/excel/worksheet.js +6 -6
- package/dist/iife/excelts.iife.js +53 -54
- package/dist/iife/excelts.iife.js.map +1 -1
- package/dist/iife/excelts.iife.min.js +24 -24
- package/package.json +1 -1
|
@@ -3,11 +3,6 @@ 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);
|
|
11
6
|
// Cell requirements
|
|
12
7
|
// Operate inside a worksheet
|
|
13
8
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -83,28 +78,23 @@ class Cell {
|
|
|
83
78
|
if (numFmt) {
|
|
84
79
|
style.numFmt = numFmt;
|
|
85
80
|
}
|
|
86
|
-
const font = (rowStyle &&
|
|
87
|
-
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
81
|
+
const font = (rowStyle && rowStyle.font) || (colStyle && colStyle.font);
|
|
88
82
|
if (font) {
|
|
89
83
|
style.font = font;
|
|
90
84
|
}
|
|
91
|
-
const alignment = (rowStyle &&
|
|
92
|
-
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
85
|
+
const alignment = (rowStyle && rowStyle.alignment) || (colStyle && colStyle.alignment);
|
|
93
86
|
if (alignment) {
|
|
94
87
|
style.alignment = alignment;
|
|
95
88
|
}
|
|
96
|
-
const border = (rowStyle &&
|
|
97
|
-
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
89
|
+
const border = (rowStyle && rowStyle.border) || (colStyle && colStyle.border);
|
|
98
90
|
if (border) {
|
|
99
91
|
style.border = border;
|
|
100
92
|
}
|
|
101
|
-
const fill = (rowStyle &&
|
|
102
|
-
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
93
|
+
const fill = (rowStyle && rowStyle.fill) || (colStyle && colStyle.fill);
|
|
103
94
|
if (fill) {
|
|
104
95
|
style.fill = fill;
|
|
105
96
|
}
|
|
106
|
-
const protection = (rowStyle &&
|
|
107
|
-
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
97
|
+
const protection = (rowStyle && rowStyle.protection) || (colStyle && colStyle.protection);
|
|
108
98
|
if (protection) {
|
|
109
99
|
style.protection = protection;
|
|
110
100
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
class Row {
|
|
6
5
|
constructor(worksheet, number) {
|
|
7
6
|
this._worksheet = worksheet;
|
|
@@ -96,7 +95,7 @@ class Row {
|
|
|
96
95
|
if (cSrc) {
|
|
97
96
|
cDst = this.getCell(i);
|
|
98
97
|
cDst.value = cSrc.value;
|
|
99
|
-
cDst.style =
|
|
98
|
+
cDst.style = cSrc.style;
|
|
100
99
|
cDst.comment = cSrc.comment;
|
|
101
100
|
}
|
|
102
101
|
else if (cDst) {
|
|
@@ -113,7 +112,7 @@ class Row {
|
|
|
113
112
|
if (cSrc) {
|
|
114
113
|
cDst = this.getCell(i + nExpand);
|
|
115
114
|
cDst.value = cSrc.value;
|
|
116
|
-
cDst.style =
|
|
115
|
+
cDst.style = cSrc.style;
|
|
117
116
|
cDst.comment = cSrc.comment;
|
|
118
117
|
}
|
|
119
118
|
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 =
|
|
511
|
+
rDst.style = rSrc.style;
|
|
512
512
|
rDst.height = rSrc.height;
|
|
513
513
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
514
|
-
rDst.getCell(colNumber).style =
|
|
514
|
+
rDst.getCell(colNumber).style = 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 =
|
|
602
|
+
rDst.style = rSrc.style;
|
|
603
603
|
rDst.height = rSrc.height;
|
|
604
604
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
605
|
-
rDst.getCell(colNumber).style =
|
|
605
|
+
rDst.getCell(colNumber).style = 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 =
|
|
621
|
+
rDst.style = rSrc.style;
|
|
622
622
|
rDst.height = rSrc.height;
|
|
623
623
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
624
|
-
rDst.getCell(colNumber).style =
|
|
624
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
627
|
else {
|
|
@@ -6,11 +6,6 @@ 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);
|
|
14
9
|
// Cell requirements
|
|
15
10
|
// Operate inside a worksheet
|
|
16
11
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -86,28 +81,23 @@ class Cell {
|
|
|
86
81
|
if (numFmt) {
|
|
87
82
|
style.numFmt = numFmt;
|
|
88
83
|
}
|
|
89
|
-
const font = (rowStyle &&
|
|
90
|
-
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
84
|
+
const font = (rowStyle && rowStyle.font) || (colStyle && colStyle.font);
|
|
91
85
|
if (font) {
|
|
92
86
|
style.font = font;
|
|
93
87
|
}
|
|
94
|
-
const alignment = (rowStyle &&
|
|
95
|
-
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
88
|
+
const alignment = (rowStyle && rowStyle.alignment) || (colStyle && colStyle.alignment);
|
|
96
89
|
if (alignment) {
|
|
97
90
|
style.alignment = alignment;
|
|
98
91
|
}
|
|
99
|
-
const border = (rowStyle &&
|
|
100
|
-
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
92
|
+
const border = (rowStyle && rowStyle.border) || (colStyle && colStyle.border);
|
|
101
93
|
if (border) {
|
|
102
94
|
style.border = border;
|
|
103
95
|
}
|
|
104
|
-
const fill = (rowStyle &&
|
|
105
|
-
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
96
|
+
const fill = (rowStyle && rowStyle.fill) || (colStyle && colStyle.fill);
|
|
106
97
|
if (fill) {
|
|
107
98
|
style.fill = fill;
|
|
108
99
|
}
|
|
109
|
-
const protection = (rowStyle &&
|
|
110
|
-
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
100
|
+
const protection = (rowStyle && rowStyle.protection) || (colStyle && colStyle.protection);
|
|
111
101
|
if (protection) {
|
|
112
102
|
style.protection = protection;
|
|
113
103
|
}
|
|
@@ -4,7 +4,6 @@ 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");
|
|
8
7
|
class Row {
|
|
9
8
|
constructor(worksheet, number) {
|
|
10
9
|
this._worksheet = worksheet;
|
|
@@ -99,7 +98,7 @@ class Row {
|
|
|
99
98
|
if (cSrc) {
|
|
100
99
|
cDst = this.getCell(i);
|
|
101
100
|
cDst.value = cSrc.value;
|
|
102
|
-
cDst.style =
|
|
101
|
+
cDst.style = cSrc.style;
|
|
103
102
|
cDst.comment = cSrc.comment;
|
|
104
103
|
}
|
|
105
104
|
else if (cDst) {
|
|
@@ -116,7 +115,7 @@ class Row {
|
|
|
116
115
|
if (cSrc) {
|
|
117
116
|
cDst = this.getCell(i + nExpand);
|
|
118
117
|
cDst.value = cSrc.value;
|
|
119
|
-
cDst.style =
|
|
118
|
+
cDst.style = cSrc.style;
|
|
120
119
|
cDst.comment = cSrc.comment;
|
|
121
120
|
}
|
|
122
121
|
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 =
|
|
514
|
+
rDst.style = rSrc.style;
|
|
515
515
|
rDst.height = rSrc.height;
|
|
516
516
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
517
|
-
rDst.getCell(colNumber).style =
|
|
517
|
+
rDst.getCell(colNumber).style = 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 =
|
|
605
|
+
rDst.style = rSrc.style;
|
|
606
606
|
rDst.height = rSrc.height;
|
|
607
607
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
608
|
-
rDst.getCell(colNumber).style =
|
|
608
|
+
rDst.getCell(colNumber).style = 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 =
|
|
624
|
+
rDst.style = rSrc.style;
|
|
625
625
|
rDst.height = rSrc.height;
|
|
626
626
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
627
|
-
rDst.getCell(colNumber).style =
|
|
627
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
630
|
else {
|
|
@@ -3,11 +3,6 @@ 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);
|
|
11
6
|
// Cell requirements
|
|
12
7
|
// Operate inside a worksheet
|
|
13
8
|
// Store and retrieve a value with a range of types: text, number, date, hyperlink, reference, formula, etc.
|
|
@@ -83,28 +78,23 @@ class Cell {
|
|
|
83
78
|
if (numFmt) {
|
|
84
79
|
style.numFmt = numFmt;
|
|
85
80
|
}
|
|
86
|
-
const font = (rowStyle &&
|
|
87
|
-
(colStyle && hasOwnKeys(colStyle.font) && colStyle.font);
|
|
81
|
+
const font = (rowStyle && rowStyle.font) || (colStyle && colStyle.font);
|
|
88
82
|
if (font) {
|
|
89
83
|
style.font = font;
|
|
90
84
|
}
|
|
91
|
-
const alignment = (rowStyle &&
|
|
92
|
-
(colStyle && hasOwnKeys(colStyle.alignment) && colStyle.alignment);
|
|
85
|
+
const alignment = (rowStyle && rowStyle.alignment) || (colStyle && colStyle.alignment);
|
|
93
86
|
if (alignment) {
|
|
94
87
|
style.alignment = alignment;
|
|
95
88
|
}
|
|
96
|
-
const border = (rowStyle &&
|
|
97
|
-
(colStyle && hasOwnKeys(colStyle.border) && colStyle.border);
|
|
89
|
+
const border = (rowStyle && rowStyle.border) || (colStyle && colStyle.border);
|
|
98
90
|
if (border) {
|
|
99
91
|
style.border = border;
|
|
100
92
|
}
|
|
101
|
-
const fill = (rowStyle &&
|
|
102
|
-
(colStyle && hasOwnKeys(colStyle.fill) && colStyle.fill);
|
|
93
|
+
const fill = (rowStyle && rowStyle.fill) || (colStyle && colStyle.fill);
|
|
103
94
|
if (fill) {
|
|
104
95
|
style.fill = fill;
|
|
105
96
|
}
|
|
106
|
-
const protection = (rowStyle &&
|
|
107
|
-
(colStyle && hasOwnKeys(colStyle.protection) && colStyle.protection);
|
|
97
|
+
const protection = (rowStyle && rowStyle.protection) || (colStyle && colStyle.protection);
|
|
108
98
|
if (protection) {
|
|
109
99
|
style.protection = protection;
|
|
110
100
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
class Row {
|
|
6
5
|
constructor(worksheet, number) {
|
|
7
6
|
this._worksheet = worksheet;
|
|
@@ -96,7 +95,7 @@ class Row {
|
|
|
96
95
|
if (cSrc) {
|
|
97
96
|
cDst = this.getCell(i);
|
|
98
97
|
cDst.value = cSrc.value;
|
|
99
|
-
cDst.style =
|
|
98
|
+
cDst.style = cSrc.style;
|
|
100
99
|
cDst.comment = cSrc.comment;
|
|
101
100
|
}
|
|
102
101
|
else if (cDst) {
|
|
@@ -113,7 +112,7 @@ class Row {
|
|
|
113
112
|
if (cSrc) {
|
|
114
113
|
cDst = this.getCell(i + nExpand);
|
|
115
114
|
cDst.value = cSrc.value;
|
|
116
|
-
cDst.style =
|
|
115
|
+
cDst.style = cSrc.style;
|
|
117
116
|
cDst.comment = cSrc.comment;
|
|
118
117
|
}
|
|
119
118
|
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 =
|
|
511
|
+
rDst.style = rSrc.style;
|
|
512
512
|
rDst.height = rSrc.height;
|
|
513
513
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
514
|
-
rDst.getCell(colNumber).style =
|
|
514
|
+
rDst.getCell(colNumber).style = 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 =
|
|
602
|
+
rDst.style = rSrc.style;
|
|
603
603
|
rDst.height = rSrc.height;
|
|
604
604
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
605
|
-
rDst.getCell(colNumber).style =
|
|
605
|
+
rDst.getCell(colNumber).style = 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 =
|
|
621
|
+
rDst.style = rSrc.style;
|
|
622
622
|
rDst.height = rSrc.height;
|
|
623
623
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
624
|
-
rDst.getCell(colNumber).style =
|
|
624
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
627
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cj-tech-master/excelts v5.1.9
|
|
2
|
+
* @cj-tech-master/excelts v5.1.9
|
|
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,7 +651,6 @@ 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);
|
|
655
654
|
var Cell = class Cell {
|
|
656
655
|
static {
|
|
657
656
|
this.Types = Enums.ValueType;
|
|
@@ -718,15 +717,15 @@ var ExcelTS = (function(exports) {
|
|
|
718
717
|
_mergeStyle(rowStyle, colStyle, style) {
|
|
719
718
|
const numFmt = rowStyle && rowStyle.numFmt || colStyle && colStyle.numFmt;
|
|
720
719
|
if (numFmt) style.numFmt = numFmt;
|
|
721
|
-
const font = rowStyle &&
|
|
720
|
+
const font = rowStyle && rowStyle.font || colStyle && colStyle.font;
|
|
722
721
|
if (font) style.font = font;
|
|
723
|
-
const alignment = rowStyle &&
|
|
722
|
+
const alignment = rowStyle && rowStyle.alignment || colStyle && colStyle.alignment;
|
|
724
723
|
if (alignment) style.alignment = alignment;
|
|
725
|
-
const border = rowStyle &&
|
|
724
|
+
const border = rowStyle && rowStyle.border || colStyle && colStyle.border;
|
|
726
725
|
if (border) style.border = border;
|
|
727
|
-
const fill = rowStyle &&
|
|
726
|
+
const fill = rowStyle && rowStyle.fill || colStyle && colStyle.fill;
|
|
728
727
|
if (fill) style.fill = fill;
|
|
729
|
-
const protection = rowStyle &&
|
|
728
|
+
const protection = rowStyle && rowStyle.protection || colStyle && colStyle.protection;
|
|
730
729
|
if (protection) style.protection = protection;
|
|
731
730
|
return style;
|
|
732
731
|
}
|
|
@@ -1524,45 +1523,6 @@ var ExcelTS = (function(exports) {
|
|
|
1524
1523
|
}
|
|
1525
1524
|
};
|
|
1526
1525
|
|
|
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
|
-
|
|
1566
1526
|
//#endregion
|
|
1567
1527
|
//#region src/modules/excel/row.ts
|
|
1568
1528
|
var Row = class {
|
|
@@ -1647,7 +1607,7 @@ var ExcelTS = (function(exports) {
|
|
|
1647
1607
|
if (cSrc) {
|
|
1648
1608
|
cDst = this.getCell(i);
|
|
1649
1609
|
cDst.value = cSrc.value;
|
|
1650
|
-
cDst.style =
|
|
1610
|
+
cDst.style = cSrc.style;
|
|
1651
1611
|
cDst.comment = cSrc.comment;
|
|
1652
1612
|
} else if (cDst) {
|
|
1653
1613
|
cDst.value = null;
|
|
@@ -1660,7 +1620,7 @@ var ExcelTS = (function(exports) {
|
|
|
1660
1620
|
if (cSrc) {
|
|
1661
1621
|
cDst = this.getCell(i + nExpand);
|
|
1662
1622
|
cDst.value = cSrc.value;
|
|
1663
|
-
cDst.style =
|
|
1623
|
+
cDst.style = cSrc.style;
|
|
1664
1624
|
cDst.comment = cSrc.comment;
|
|
1665
1625
|
} else this._cells[i + nExpand - 1] = void 0;
|
|
1666
1626
|
}
|
|
@@ -5757,6 +5717,45 @@ var ExcelTS = (function(exports) {
|
|
|
5757
5717
|
return result;
|
|
5758
5718
|
}
|
|
5759
5719
|
|
|
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
|
+
|
|
5760
5759
|
//#endregion
|
|
5761
5760
|
//#region src/modules/excel/worksheet.ts
|
|
5762
5761
|
var Worksheet = class {
|
|
@@ -6114,10 +6113,10 @@ var ExcelTS = (function(exports) {
|
|
|
6114
6113
|
this.spliceRows(rowNum + 1, insert ? 0 : count, ...inserts);
|
|
6115
6114
|
for (let i = 0; i < count; i++) {
|
|
6116
6115
|
const rDst = this._rows[rowNum + i];
|
|
6117
|
-
rDst.style =
|
|
6116
|
+
rDst.style = rSrc.style;
|
|
6118
6117
|
rDst.height = rSrc.height;
|
|
6119
6118
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6120
|
-
rDst.getCell(colNumber).style =
|
|
6119
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
6121
6120
|
});
|
|
6122
6121
|
}
|
|
6123
6122
|
if (srcMerges.length > 0) for (let i = 0; i < count; i++) {
|
|
@@ -6177,10 +6176,10 @@ var ExcelTS = (function(exports) {
|
|
|
6177
6176
|
if (rSrc) {
|
|
6178
6177
|
const rDst = this.getRow(i + nExpand);
|
|
6179
6178
|
rDst.values = rSrc.values;
|
|
6180
|
-
rDst.style =
|
|
6179
|
+
rDst.style = rSrc.style;
|
|
6181
6180
|
rDst.height = rSrc.height;
|
|
6182
6181
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6183
|
-
rDst.getCell(colNumber).style =
|
|
6182
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
6184
6183
|
});
|
|
6185
6184
|
this._rows[i - 1] = void 0;
|
|
6186
6185
|
} else this._rows[i + nExpand - 1] = void 0;
|
|
@@ -6190,10 +6189,10 @@ var ExcelTS = (function(exports) {
|
|
|
6190
6189
|
if (rSrc) {
|
|
6191
6190
|
const rDst = this.getRow(i + nExpand);
|
|
6192
6191
|
rDst.values = rSrc.values;
|
|
6193
|
-
rDst.style =
|
|
6192
|
+
rDst.style = rSrc.style;
|
|
6194
6193
|
rDst.height = rSrc.height;
|
|
6195
6194
|
rSrc.eachCell({ includeEmpty: true }, (cell, colNumber) => {
|
|
6196
|
-
rDst.getCell(colNumber).style =
|
|
6195
|
+
rDst.getCell(colNumber).style = cell.style;
|
|
6197
6196
|
});
|
|
6198
6197
|
} else this._rows[i + nExpand - 1] = void 0;
|
|
6199
6198
|
}
|