@corbe30/fortune-excel 1.0.3
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/.github/workflows/main.yml +30 -0
- package/.github/workflows/publish.yml +30 -0
- package/.storybook/main.ts +18 -0
- package/.storybook/preview.ts +15 -0
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/HandleZip.d.ts +8 -0
- package/dist/HandleZip.js +37 -0
- package/dist/ICommon.d.ts +34 -0
- package/dist/ICommon.js +1 -0
- package/dist/ToExcel/ExcelBorder.d.ts +3 -0
- package/dist/ToExcel/ExcelBorder.js +1412 -0
- package/dist/ToExcel/ExcelConvert.d.ts +16 -0
- package/dist/ToExcel/ExcelConvert.js +92 -0
- package/dist/ToExcel/ExcelFile.d.ts +1 -0
- package/dist/ToExcel/ExcelFile.js +30 -0
- package/dist/ToExcel/ExcelImage.d.ts +2 -0
- package/dist/ToExcel/ExcelImage.js +64 -0
- package/dist/ToExcel/ExcelStyle.d.ts +3 -0
- package/dist/ToExcel/ExcelStyle.js +53 -0
- package/dist/ToFortuneSheet/FortuneBase.d.ts +133 -0
- package/dist/ToFortuneSheet/FortuneBase.js +28 -0
- package/dist/ToFortuneSheet/FortuneCell.d.ts +25 -0
- package/dist/ToFortuneSheet/FortuneCell.js +782 -0
- package/dist/ToFortuneSheet/FortuneFile.d.ts +50 -0
- package/dist/ToFortuneSheet/FortuneFile.js +432 -0
- package/dist/ToFortuneSheet/FortuneImage.d.ts +20 -0
- package/dist/ToFortuneSheet/FortuneImage.js +51 -0
- package/dist/ToFortuneSheet/FortuneSheet.d.ts +36 -0
- package/dist/ToFortuneSheet/FortuneSheet.js +581 -0
- package/dist/ToFortuneSheet/IFortune.d.ts +301 -0
- package/dist/ToFortuneSheet/IFortune.js +1 -0
- package/dist/ToFortuneSheet/ReadXml.d.ts +61 -0
- package/dist/ToFortuneSheet/ReadXml.js +337 -0
- package/dist/common/constant.d.ts +25 -0
- package/dist/common/constant.js +277 -0
- package/dist/common/emf.d.ts +3 -0
- package/dist/common/emf.js +1294 -0
- package/dist/common/method.d.ts +132 -0
- package/dist/common/method.js +1075 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +24 -0
- package/package.json +47 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { getColor, getlineStringAttr, } from "./ReadXml.js";
|
|
2
|
+
import { getcellrange, escapeCharacter, isChinese, isJapanese, isKoera, } from "../common/method.js";
|
|
3
|
+
import { ST_CellType, borderTypes, fontFamilys, } from "../common/constant.js";
|
|
4
|
+
import { FortuneSheetborderInfoCellValueStyle, FortuneSheetborderInfoCellForImp, FortuneSheetborderInfoCellValue, FortuneSheetCelldataBase, FortuneSheetCelldataValue, FortuneSheetCellFormat, } from "./FortuneBase.js";
|
|
5
|
+
export class FortuneSheetCelldata extends FortuneSheetCelldataBase {
|
|
6
|
+
constructor(cell, styles, sharedStrings, mergeCells, sheetFile, ReadXml) {
|
|
7
|
+
//Private
|
|
8
|
+
super();
|
|
9
|
+
this.cell = cell;
|
|
10
|
+
this.sheetFile = sheetFile;
|
|
11
|
+
this.styles = styles;
|
|
12
|
+
this.sharedStrings = sharedStrings;
|
|
13
|
+
this.readXml = ReadXml;
|
|
14
|
+
this.mergeCells = mergeCells;
|
|
15
|
+
let attrList = cell.attributeList;
|
|
16
|
+
let r = attrList.r, s = attrList.s, t = attrList.t;
|
|
17
|
+
let range = getcellrange(r);
|
|
18
|
+
this.r = range.row[0];
|
|
19
|
+
this.c = range.column[0];
|
|
20
|
+
this.v = this.generateValue(s, t);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @param s Style index ,start 1
|
|
24
|
+
* @param t Cell type, Optional value is ST_CellType, it's found at constat.ts
|
|
25
|
+
*/
|
|
26
|
+
generateValue(s, t) {
|
|
27
|
+
let v = this.cell.getInnerElements("v");
|
|
28
|
+
let f = this.cell.getInnerElements("f");
|
|
29
|
+
if (v == null) {
|
|
30
|
+
v = this.cell.getInnerElements("t");
|
|
31
|
+
}
|
|
32
|
+
let cellXfs = this.styles["cellXfs"];
|
|
33
|
+
let cellStyleXfs = this.styles["cellStyleXfs"];
|
|
34
|
+
let cellStyles = this.styles["cellStyles"];
|
|
35
|
+
let fonts = this.styles["fonts"];
|
|
36
|
+
let fills = this.styles["fills"];
|
|
37
|
+
let borders = this.styles["borders"];
|
|
38
|
+
let numfmts = this.styles["numfmts"];
|
|
39
|
+
let clrScheme = this.styles["clrScheme"];
|
|
40
|
+
let sharedStrings = this.sharedStrings;
|
|
41
|
+
let cellValue = new FortuneSheetCelldataValue();
|
|
42
|
+
if (f != null) {
|
|
43
|
+
let formula = f[0], attrList = formula.attributeList;
|
|
44
|
+
let t = attrList.t, ref = attrList.ref, si = attrList.si;
|
|
45
|
+
let formulaValue = f[0].value;
|
|
46
|
+
if (t == "shared") {
|
|
47
|
+
this._fomulaRef = ref;
|
|
48
|
+
this._formulaType = t;
|
|
49
|
+
this._formulaSi = si;
|
|
50
|
+
}
|
|
51
|
+
// console.log(ref, t, si);
|
|
52
|
+
if (ref != null || (formulaValue != null && formulaValue.length > 0)) {
|
|
53
|
+
formulaValue = escapeCharacter(formulaValue);
|
|
54
|
+
cellValue.f = "=" + formulaValue;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let familyFont = null;
|
|
58
|
+
let quotePrefix;
|
|
59
|
+
if (s != null) {
|
|
60
|
+
let sNum = parseInt(s);
|
|
61
|
+
let cellXf = cellXfs[sNum];
|
|
62
|
+
let xfId = cellXf.attributeList.xfId;
|
|
63
|
+
let numFmtId, fontId, fillId, borderId;
|
|
64
|
+
let horizontal, vertical, wrapText, textRotation, shrinkToFit, indent, applyProtection;
|
|
65
|
+
if (xfId != null) {
|
|
66
|
+
let cellStyleXf = cellStyleXfs[parseInt(xfId)];
|
|
67
|
+
let attrList = cellStyleXf.attributeList;
|
|
68
|
+
let applyNumberFormat = attrList.applyNumberFormat;
|
|
69
|
+
let applyFont = attrList.applyFont;
|
|
70
|
+
let applyFill = attrList.applyFill;
|
|
71
|
+
let applyBorder = attrList.applyBorder;
|
|
72
|
+
let applyAlignment = attrList.applyAlignment;
|
|
73
|
+
// let applyProtection = attrList.applyProtection;
|
|
74
|
+
applyProtection = attrList.applyProtection;
|
|
75
|
+
quotePrefix = attrList.quotePrefix;
|
|
76
|
+
if (applyNumberFormat != "0" && attrList.numFmtId != null) {
|
|
77
|
+
// if(attrList.numFmtId!="0"){
|
|
78
|
+
numFmtId = attrList.numFmtId;
|
|
79
|
+
// }
|
|
80
|
+
}
|
|
81
|
+
if (applyFont != "0" && attrList.fontId != null) {
|
|
82
|
+
fontId = attrList.fontId;
|
|
83
|
+
}
|
|
84
|
+
if (applyFill != "0" && attrList.fillId != null) {
|
|
85
|
+
fillId = attrList.fillId;
|
|
86
|
+
}
|
|
87
|
+
if (applyBorder != "0" && attrList.borderId != null) {
|
|
88
|
+
borderId = attrList.borderId;
|
|
89
|
+
}
|
|
90
|
+
if (applyAlignment != null && applyAlignment != "0") {
|
|
91
|
+
let alignment = cellStyleXf.getInnerElements("alignment");
|
|
92
|
+
if (alignment != null) {
|
|
93
|
+
let attrList = alignment[0].attributeList;
|
|
94
|
+
if (attrList.horizontal != null) {
|
|
95
|
+
horizontal = attrList.horizontal;
|
|
96
|
+
}
|
|
97
|
+
if (attrList.vertical != null) {
|
|
98
|
+
vertical = attrList.vertical;
|
|
99
|
+
}
|
|
100
|
+
if (attrList.wrapText != null) {
|
|
101
|
+
wrapText = attrList.wrapText;
|
|
102
|
+
}
|
|
103
|
+
if (attrList.textRotation != null) {
|
|
104
|
+
textRotation = attrList.textRotation;
|
|
105
|
+
}
|
|
106
|
+
if (attrList.shrinkToFit != null) {
|
|
107
|
+
shrinkToFit = attrList.shrinkToFit;
|
|
108
|
+
}
|
|
109
|
+
if (attrList.indent != null) {
|
|
110
|
+
indent = attrList.indent;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
let applyNumberFormat = cellXf.attributeList.applyNumberFormat;
|
|
116
|
+
let applyFont = cellXf.attributeList.applyFont;
|
|
117
|
+
let applyFill = cellXf.attributeList.applyFill;
|
|
118
|
+
let applyBorder = cellXf.attributeList.applyBorder;
|
|
119
|
+
let applyAlignment = cellXf.attributeList.applyAlignment;
|
|
120
|
+
if (cellXf.attributeList.applyProtection != null) {
|
|
121
|
+
applyProtection = cellXf.attributeList.applyProtection;
|
|
122
|
+
}
|
|
123
|
+
if (cellXf.attributeList.quotePrefix != null) {
|
|
124
|
+
quotePrefix = cellXf.attributeList.quotePrefix;
|
|
125
|
+
}
|
|
126
|
+
if (applyNumberFormat != "0" && cellXf.attributeList.numFmtId != null) {
|
|
127
|
+
numFmtId = cellXf.attributeList.numFmtId;
|
|
128
|
+
}
|
|
129
|
+
if (applyFont != "0") {
|
|
130
|
+
fontId = cellXf.attributeList.fontId;
|
|
131
|
+
}
|
|
132
|
+
if (applyFill != "0") {
|
|
133
|
+
fillId = cellXf.attributeList.fillId;
|
|
134
|
+
}
|
|
135
|
+
if (applyBorder != "0") {
|
|
136
|
+
borderId = cellXf.attributeList.borderId;
|
|
137
|
+
}
|
|
138
|
+
if (applyAlignment != "0") {
|
|
139
|
+
let alignment = cellXf.getInnerElements("alignment");
|
|
140
|
+
if (alignment != null && alignment.length > 0) {
|
|
141
|
+
let attrList = alignment[0].attributeList;
|
|
142
|
+
if (attrList.horizontal != null) {
|
|
143
|
+
horizontal = attrList.horizontal;
|
|
144
|
+
}
|
|
145
|
+
if (attrList.vertical != null) {
|
|
146
|
+
vertical = attrList.vertical;
|
|
147
|
+
}
|
|
148
|
+
if (attrList.wrapText != null) {
|
|
149
|
+
wrapText = attrList.wrapText;
|
|
150
|
+
}
|
|
151
|
+
if (attrList.textRotation != null) {
|
|
152
|
+
textRotation = attrList.textRotation;
|
|
153
|
+
}
|
|
154
|
+
if (attrList.shrinkToFit != null) {
|
|
155
|
+
shrinkToFit = attrList.shrinkToFit;
|
|
156
|
+
}
|
|
157
|
+
if (attrList.indent != null) {
|
|
158
|
+
indent = attrList.indent;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (numFmtId != undefined) {
|
|
163
|
+
let numf = numfmts[parseInt(numFmtId)];
|
|
164
|
+
let cellFormat = new FortuneSheetCellFormat();
|
|
165
|
+
cellFormat.fa = escapeCharacter(numf);
|
|
166
|
+
// console.log(numf, numFmtId, this.v);
|
|
167
|
+
cellFormat.t = t || "n";
|
|
168
|
+
cellValue.ct = cellFormat;
|
|
169
|
+
}
|
|
170
|
+
if (fillId != undefined) {
|
|
171
|
+
let fillIdNum = parseInt(fillId);
|
|
172
|
+
let fill = fills[fillIdNum];
|
|
173
|
+
// console.log(cellValue.v);
|
|
174
|
+
let bg = this.getBackgroundByFill(fill, clrScheme);
|
|
175
|
+
if (bg != null) {
|
|
176
|
+
cellValue.bg = bg;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (fontId != undefined) {
|
|
180
|
+
let fontIdNum = parseInt(fontId);
|
|
181
|
+
let font = fonts[fontIdNum];
|
|
182
|
+
if (font != null) {
|
|
183
|
+
let sz = font.getInnerElements("sz"); //font size
|
|
184
|
+
let colors = font.getInnerElements("color"); //font color
|
|
185
|
+
let family = font.getInnerElements("name"); //font family
|
|
186
|
+
let familyOverrides = font.getInnerElements("family"); //font family will be overrided by name
|
|
187
|
+
let charset = font.getInnerElements("charset"); //font charset
|
|
188
|
+
let bolds = font.getInnerElements("b"); //font bold
|
|
189
|
+
let italics = font.getInnerElements("i"); //font italic
|
|
190
|
+
let strikes = font.getInnerElements("strike"); //font italic
|
|
191
|
+
let underlines = font.getInnerElements("u"); //font italic
|
|
192
|
+
if (sz != null && sz.length > 0) {
|
|
193
|
+
let fs = sz[0].attributeList.val;
|
|
194
|
+
if (fs != null) {
|
|
195
|
+
cellValue.fs = parseInt(fs);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (colors != null && colors.length > 0) {
|
|
199
|
+
let color = colors[0];
|
|
200
|
+
let fc = getColor(color, this.styles, "t");
|
|
201
|
+
if (fc != null) {
|
|
202
|
+
cellValue.fc = fc;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (familyOverrides != null && familyOverrides.length > 0) {
|
|
206
|
+
let val = familyOverrides[0].attributeList.val;
|
|
207
|
+
if (val != null) {
|
|
208
|
+
familyFont = fontFamilys[val];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (family != null && family.length > 0) {
|
|
212
|
+
let val = family[0].attributeList.val;
|
|
213
|
+
if (val != null) {
|
|
214
|
+
cellValue.ff = val;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (bolds != null && bolds.length > 0) {
|
|
218
|
+
let bold = bolds[0].attributeList.val;
|
|
219
|
+
if (bold == "0") {
|
|
220
|
+
cellValue.bl = 0;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
cellValue.bl = 1;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (italics != null && italics.length > 0) {
|
|
227
|
+
let italic = italics[0].attributeList.val;
|
|
228
|
+
if (italic == "0") {
|
|
229
|
+
cellValue.it = 0;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
cellValue.it = 1;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (strikes != null && strikes.length > 0) {
|
|
236
|
+
let strike = strikes[0].attributeList.val;
|
|
237
|
+
if (strike == "0") {
|
|
238
|
+
cellValue.cl = 0;
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
cellValue.cl = 1;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (underlines != null && underlines.length > 0) {
|
|
245
|
+
let underline = underlines[0].attributeList.val;
|
|
246
|
+
if (underline == "single") {
|
|
247
|
+
cellValue.un = 1;
|
|
248
|
+
}
|
|
249
|
+
else if (underline == "double") {
|
|
250
|
+
cellValue.un = 2;
|
|
251
|
+
}
|
|
252
|
+
else if (underline == "singleAccounting") {
|
|
253
|
+
cellValue.un = 3;
|
|
254
|
+
}
|
|
255
|
+
else if (underline == "doubleAccounting") {
|
|
256
|
+
cellValue.un = 4;
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
cellValue.un = 0;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// vt: number | undefined//Vertical alignment, 0 middle, 1 up, 2 down, alignment
|
|
265
|
+
// ht: number | undefined//Horizontal alignment,0 center, 1 left, 2 right, alignment
|
|
266
|
+
// tr: number | undefined //Text rotation,0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90, alignment
|
|
267
|
+
// tb: number | undefined //Text wrap,0 truncation, 1 overflow, 2 word wrap, alignment
|
|
268
|
+
if (horizontal != undefined) {
|
|
269
|
+
//Horizontal alignment
|
|
270
|
+
if (horizontal == "center") {
|
|
271
|
+
cellValue.ht = 0;
|
|
272
|
+
}
|
|
273
|
+
else if (horizontal == "centerContinuous") {
|
|
274
|
+
cellValue.ht = 0; //fortunesheet unsupport
|
|
275
|
+
}
|
|
276
|
+
else if (horizontal == "left") {
|
|
277
|
+
cellValue.ht = 1;
|
|
278
|
+
}
|
|
279
|
+
else if (horizontal == "right") {
|
|
280
|
+
cellValue.ht = 2;
|
|
281
|
+
}
|
|
282
|
+
else if (horizontal == "distributed") {
|
|
283
|
+
cellValue.ht = 0; //fortunesheet unsupport
|
|
284
|
+
}
|
|
285
|
+
else if (horizontal == "fill") {
|
|
286
|
+
cellValue.ht = 1; //fortunesheet unsupport
|
|
287
|
+
}
|
|
288
|
+
else if (horizontal == "general") {
|
|
289
|
+
cellValue.ht = 1; //fortunesheet unsupport
|
|
290
|
+
}
|
|
291
|
+
else if (horizontal == "justify") {
|
|
292
|
+
cellValue.ht = 0; //fortunesheet unsupport
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
cellValue.ht = 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (vertical != undefined) {
|
|
299
|
+
//Vertical alignment
|
|
300
|
+
if (vertical == "bottom") {
|
|
301
|
+
cellValue.vt = 2;
|
|
302
|
+
}
|
|
303
|
+
else if (vertical == "center") {
|
|
304
|
+
cellValue.vt = 0;
|
|
305
|
+
}
|
|
306
|
+
else if (vertical == "distributed") {
|
|
307
|
+
cellValue.vt = 0; //fortunesheet unsupport
|
|
308
|
+
}
|
|
309
|
+
else if (vertical == "justify") {
|
|
310
|
+
cellValue.vt = 0; //fortunesheet unsupport
|
|
311
|
+
}
|
|
312
|
+
else if (vertical == "top") {
|
|
313
|
+
cellValue.vt = 1;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
cellValue.vt = 1;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
//sometimes bottom style is lost after setting it in excel
|
|
321
|
+
//when vertical is undefined set it to 2.
|
|
322
|
+
cellValue.vt = 2;
|
|
323
|
+
}
|
|
324
|
+
if (wrapText != undefined) {
|
|
325
|
+
if (wrapText == "1") {
|
|
326
|
+
cellValue.tb = 2;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
cellValue.tb = 1;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
cellValue.tb = 1;
|
|
334
|
+
}
|
|
335
|
+
if (textRotation != undefined) {
|
|
336
|
+
// tr: number | undefined //Text rotation,0: 0、1: 45 、2: -45、3 Vertical text、4: 90 、5: -90, alignment
|
|
337
|
+
if (textRotation == "255") {
|
|
338
|
+
cellValue.tr = 3;
|
|
339
|
+
}
|
|
340
|
+
// else if(textRotation=="45"){
|
|
341
|
+
// cellValue.tr = 1;
|
|
342
|
+
// }
|
|
343
|
+
// else if(textRotation=="90"){
|
|
344
|
+
// cellValue.tr = 4;
|
|
345
|
+
// }
|
|
346
|
+
// else if(textRotation=="135"){
|
|
347
|
+
// cellValue.tr = 2;
|
|
348
|
+
// }
|
|
349
|
+
// else if(textRotation=="180"){
|
|
350
|
+
// cellValue.tr = 5;
|
|
351
|
+
// }
|
|
352
|
+
else {
|
|
353
|
+
cellValue.tr = 0;
|
|
354
|
+
cellValue.rt = parseInt(textRotation);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
if (shrinkToFit != undefined) {
|
|
358
|
+
//fortunesheet unsupport
|
|
359
|
+
}
|
|
360
|
+
if (indent != undefined) {
|
|
361
|
+
//fortunesheet unsupport
|
|
362
|
+
}
|
|
363
|
+
if (borderId != undefined) {
|
|
364
|
+
let borderIdNum = parseInt(borderId);
|
|
365
|
+
let border = borders[borderIdNum];
|
|
366
|
+
// this._borderId = borderIdNum;
|
|
367
|
+
let borderObject = new FortuneSheetborderInfoCellForImp();
|
|
368
|
+
borderObject.rangeType = "cell";
|
|
369
|
+
// borderObject.cells = [];
|
|
370
|
+
let borderCellValue = new FortuneSheetborderInfoCellValue();
|
|
371
|
+
borderCellValue.row_index = this.r;
|
|
372
|
+
borderCellValue.col_index = this.c;
|
|
373
|
+
let lefts = border.getInnerElements("left");
|
|
374
|
+
let rights = border.getInnerElements("right");
|
|
375
|
+
let tops = border.getInnerElements("top");
|
|
376
|
+
let bottoms = border.getInnerElements("bottom");
|
|
377
|
+
let diagonals = border.getInnerElements("diagonal");
|
|
378
|
+
let starts = border.getInnerElements("start");
|
|
379
|
+
let ends = border.getInnerElements("end");
|
|
380
|
+
let left = this.getBorderInfo(lefts);
|
|
381
|
+
let right = this.getBorderInfo(rights);
|
|
382
|
+
let top = this.getBorderInfo(tops);
|
|
383
|
+
let bottom = this.getBorderInfo(bottoms);
|
|
384
|
+
let diagonal = this.getBorderInfo(diagonals);
|
|
385
|
+
let start = this.getBorderInfo(starts);
|
|
386
|
+
let end = this.getBorderInfo(ends);
|
|
387
|
+
let isAdd = false;
|
|
388
|
+
if (start != null && start.color != null) {
|
|
389
|
+
borderCellValue.l = start;
|
|
390
|
+
isAdd = true;
|
|
391
|
+
}
|
|
392
|
+
if (end != null && end.color != null) {
|
|
393
|
+
borderCellValue.r = end;
|
|
394
|
+
isAdd = true;
|
|
395
|
+
}
|
|
396
|
+
if (left != null && left.color != null) {
|
|
397
|
+
borderCellValue.l = left;
|
|
398
|
+
isAdd = true;
|
|
399
|
+
}
|
|
400
|
+
if (right != null && right.color != null) {
|
|
401
|
+
borderCellValue.r = right;
|
|
402
|
+
isAdd = true;
|
|
403
|
+
}
|
|
404
|
+
if (top != null && top.color != null) {
|
|
405
|
+
borderCellValue.t = top;
|
|
406
|
+
isAdd = true;
|
|
407
|
+
}
|
|
408
|
+
if (bottom != null && bottom.color != null) {
|
|
409
|
+
borderCellValue.b = bottom;
|
|
410
|
+
isAdd = true;
|
|
411
|
+
}
|
|
412
|
+
if (isAdd) {
|
|
413
|
+
borderObject.value = borderCellValue;
|
|
414
|
+
// this.config._borderInfo[borderId] = borderObject;
|
|
415
|
+
this._borderObject = borderObject;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
cellValue.tb = 1;
|
|
421
|
+
}
|
|
422
|
+
if (v != null) {
|
|
423
|
+
let value = v[0].value;
|
|
424
|
+
if (/&#\d+;/.test(value)) {
|
|
425
|
+
value = this.htmlDecode(value);
|
|
426
|
+
}
|
|
427
|
+
if (t == ST_CellType["SharedString"]) {
|
|
428
|
+
let siIndex = parseInt(v[0].value);
|
|
429
|
+
let sharedSI = sharedStrings[siIndex];
|
|
430
|
+
let rFlag = sharedSI.getInnerElements("r");
|
|
431
|
+
if (rFlag == null) {
|
|
432
|
+
let tFlag = sharedSI.getInnerElements("t");
|
|
433
|
+
if (tFlag != null) {
|
|
434
|
+
let text = "";
|
|
435
|
+
tFlag.forEach((t) => {
|
|
436
|
+
text += t.value;
|
|
437
|
+
});
|
|
438
|
+
text = escapeCharacter(text);
|
|
439
|
+
//isContainMultiType(text) &&
|
|
440
|
+
if (familyFont == "Roman" && text.length > 0) {
|
|
441
|
+
let textArray = text.split("");
|
|
442
|
+
let preWordType = null, wordText = "", preWholef = null;
|
|
443
|
+
let wholef = "Times New Roman";
|
|
444
|
+
if (cellValue.ff != null) {
|
|
445
|
+
wholef = cellValue.ff;
|
|
446
|
+
}
|
|
447
|
+
let cellFormat = cellValue.ct;
|
|
448
|
+
if (cellFormat == null) {
|
|
449
|
+
cellFormat = new FortuneSheetCellFormat();
|
|
450
|
+
}
|
|
451
|
+
if (cellFormat.s == null) {
|
|
452
|
+
cellFormat.s = [];
|
|
453
|
+
}
|
|
454
|
+
for (let i = 0; i < textArray.length; i++) {
|
|
455
|
+
let w = textArray[i];
|
|
456
|
+
let type = null, ff = wholef;
|
|
457
|
+
if (isChinese(w)) {
|
|
458
|
+
type = "c";
|
|
459
|
+
ff = "宋体";
|
|
460
|
+
}
|
|
461
|
+
else if (isJapanese(w)) {
|
|
462
|
+
type = "j";
|
|
463
|
+
ff = "Yu Gothic";
|
|
464
|
+
}
|
|
465
|
+
else if (isKoera(w)) {
|
|
466
|
+
type = "k";
|
|
467
|
+
ff = "Malgun Gothic";
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
type = "e";
|
|
471
|
+
}
|
|
472
|
+
if ((type != preWordType && preWordType != null) ||
|
|
473
|
+
i == textArray.length - 1) {
|
|
474
|
+
let InlineString = {};
|
|
475
|
+
InlineString.ff = preWholef;
|
|
476
|
+
if (cellValue.fc != null) {
|
|
477
|
+
InlineString.fc = cellValue.fc;
|
|
478
|
+
}
|
|
479
|
+
if (cellValue.fs != null) {
|
|
480
|
+
InlineString.fs = cellValue.fs;
|
|
481
|
+
}
|
|
482
|
+
if (cellValue.cl != null) {
|
|
483
|
+
InlineString.cl = cellValue.cl;
|
|
484
|
+
}
|
|
485
|
+
if (cellValue.un != null) {
|
|
486
|
+
InlineString.un = cellValue.un;
|
|
487
|
+
}
|
|
488
|
+
if (cellValue.bl != null) {
|
|
489
|
+
InlineString.bl = cellValue.bl;
|
|
490
|
+
}
|
|
491
|
+
if (cellValue.it != null) {
|
|
492
|
+
InlineString.it = cellValue.it;
|
|
493
|
+
}
|
|
494
|
+
if (i == textArray.length - 1) {
|
|
495
|
+
if (type == preWordType) {
|
|
496
|
+
InlineString.ff = ff;
|
|
497
|
+
InlineString.v = wordText + w;
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
InlineString.ff = preWholef;
|
|
501
|
+
InlineString.v = wordText;
|
|
502
|
+
cellFormat.s.push(InlineString);
|
|
503
|
+
let InlineStringLast = {};
|
|
504
|
+
InlineStringLast.ff = ff;
|
|
505
|
+
InlineStringLast.v = w;
|
|
506
|
+
if (cellValue.fc != null) {
|
|
507
|
+
InlineStringLast.fc = cellValue.fc;
|
|
508
|
+
}
|
|
509
|
+
if (cellValue.fs != null) {
|
|
510
|
+
InlineStringLast.fs = cellValue.fs;
|
|
511
|
+
}
|
|
512
|
+
if (cellValue.cl != null) {
|
|
513
|
+
InlineStringLast.cl = cellValue.cl;
|
|
514
|
+
}
|
|
515
|
+
if (cellValue.un != null) {
|
|
516
|
+
InlineStringLast.un = cellValue.un;
|
|
517
|
+
}
|
|
518
|
+
if (cellValue.bl != null) {
|
|
519
|
+
InlineStringLast.bl = cellValue.bl;
|
|
520
|
+
}
|
|
521
|
+
if (cellValue.it != null) {
|
|
522
|
+
InlineStringLast.it = cellValue.it;
|
|
523
|
+
}
|
|
524
|
+
cellFormat.s.push(InlineStringLast);
|
|
525
|
+
break;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
InlineString.v = wordText;
|
|
530
|
+
}
|
|
531
|
+
cellFormat.s.push(InlineString);
|
|
532
|
+
wordText = w;
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
wordText += w;
|
|
536
|
+
}
|
|
537
|
+
preWordType = type;
|
|
538
|
+
preWholef = ff;
|
|
539
|
+
}
|
|
540
|
+
cellFormat.t = "inlineStr";
|
|
541
|
+
// cellFormat.s = [InlineString];
|
|
542
|
+
cellValue.ct = cellFormat;
|
|
543
|
+
// console.log(cellValue);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
text = this.replaceSpecialWrap(text);
|
|
547
|
+
if (text.indexOf("\r\n") > -1 || text.indexOf("\n") > -1) {
|
|
548
|
+
let InlineString = {};
|
|
549
|
+
InlineString.v = text;
|
|
550
|
+
let cellFormat = cellValue.ct;
|
|
551
|
+
if (cellFormat == null) {
|
|
552
|
+
cellFormat = new FortuneSheetCellFormat();
|
|
553
|
+
}
|
|
554
|
+
if (cellValue.ff != null) {
|
|
555
|
+
InlineString.ff = cellValue.ff;
|
|
556
|
+
}
|
|
557
|
+
if (cellValue.fc != null) {
|
|
558
|
+
InlineString.fc = cellValue.fc;
|
|
559
|
+
}
|
|
560
|
+
if (cellValue.fs != null) {
|
|
561
|
+
InlineString.fs = cellValue.fs;
|
|
562
|
+
}
|
|
563
|
+
if (cellValue.cl != null) {
|
|
564
|
+
InlineString.cl = cellValue.cl;
|
|
565
|
+
}
|
|
566
|
+
if (cellValue.un != null) {
|
|
567
|
+
InlineString.un = cellValue.un;
|
|
568
|
+
}
|
|
569
|
+
if (cellValue.bl != null) {
|
|
570
|
+
InlineString.bl = cellValue.bl;
|
|
571
|
+
}
|
|
572
|
+
if (cellValue.it != null) {
|
|
573
|
+
InlineString.it = cellValue.it;
|
|
574
|
+
}
|
|
575
|
+
cellFormat.t = "inlineStr";
|
|
576
|
+
cellFormat.s = [InlineString];
|
|
577
|
+
cellValue.ct = cellFormat;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
cellValue.v = text;
|
|
581
|
+
quotePrefix = "1";
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
let styles = [];
|
|
588
|
+
rFlag.forEach((r) => {
|
|
589
|
+
let tFlag = r.getInnerElements("t");
|
|
590
|
+
let rPr = r.getInnerElements("rPr");
|
|
591
|
+
let InlineString = {};
|
|
592
|
+
if (tFlag != null && tFlag.length > 0) {
|
|
593
|
+
let text = tFlag[0].value;
|
|
594
|
+
text = this.replaceSpecialWrap(text);
|
|
595
|
+
text = escapeCharacter(text);
|
|
596
|
+
InlineString.v = text;
|
|
597
|
+
}
|
|
598
|
+
if (rPr != null && rPr.length > 0) {
|
|
599
|
+
let frpr = rPr[0];
|
|
600
|
+
let sz = getlineStringAttr(frpr, "sz"), rFont = getlineStringAttr(frpr, "rFont"), family = getlineStringAttr(frpr, "family"), charset = getlineStringAttr(frpr, "charset"), scheme = getlineStringAttr(frpr, "scheme"), b = getlineStringAttr(frpr, "b"), i = getlineStringAttr(frpr, "i"), u = getlineStringAttr(frpr, "u"), strike = getlineStringAttr(frpr, "strike"), vertAlign = getlineStringAttr(frpr, "vertAlign"), color;
|
|
601
|
+
let cEle = frpr.getInnerElements("color");
|
|
602
|
+
if (cEle != null && cEle.length > 0) {
|
|
603
|
+
color = getColor(cEle[0], this.styles, "t");
|
|
604
|
+
}
|
|
605
|
+
let ff;
|
|
606
|
+
// if(family!=null){
|
|
607
|
+
// ff = fontFamilys[family];
|
|
608
|
+
// }
|
|
609
|
+
if (rFont != null) {
|
|
610
|
+
ff = rFont;
|
|
611
|
+
}
|
|
612
|
+
if (ff != null) {
|
|
613
|
+
InlineString.ff = ff;
|
|
614
|
+
}
|
|
615
|
+
else if (cellValue.ff != null) {
|
|
616
|
+
InlineString.ff = cellValue.ff;
|
|
617
|
+
}
|
|
618
|
+
if (color != null) {
|
|
619
|
+
InlineString.fc = color;
|
|
620
|
+
}
|
|
621
|
+
else if (cellValue.fc != null) {
|
|
622
|
+
InlineString.fc = cellValue.fc;
|
|
623
|
+
}
|
|
624
|
+
if (sz != null) {
|
|
625
|
+
InlineString.fs = parseInt(sz);
|
|
626
|
+
}
|
|
627
|
+
else if (cellValue.fs != null) {
|
|
628
|
+
InlineString.fs = cellValue.fs;
|
|
629
|
+
}
|
|
630
|
+
if (strike != null) {
|
|
631
|
+
InlineString.cl = parseInt(strike);
|
|
632
|
+
}
|
|
633
|
+
else if (cellValue.cl != null) {
|
|
634
|
+
InlineString.cl = cellValue.cl;
|
|
635
|
+
}
|
|
636
|
+
if (u != null) {
|
|
637
|
+
InlineString.un = parseInt(u);
|
|
638
|
+
}
|
|
639
|
+
else if (cellValue.un != null) {
|
|
640
|
+
InlineString.un = cellValue.un;
|
|
641
|
+
}
|
|
642
|
+
if (b != null) {
|
|
643
|
+
InlineString.bl = parseInt(b);
|
|
644
|
+
}
|
|
645
|
+
else if (cellValue.bl != null) {
|
|
646
|
+
InlineString.bl = cellValue.bl;
|
|
647
|
+
}
|
|
648
|
+
if (i != null) {
|
|
649
|
+
InlineString.it = parseInt(i);
|
|
650
|
+
}
|
|
651
|
+
else if (cellValue.it != null) {
|
|
652
|
+
InlineString.it = cellValue.it;
|
|
653
|
+
}
|
|
654
|
+
if (vertAlign != null) {
|
|
655
|
+
InlineString.va = parseInt(vertAlign);
|
|
656
|
+
}
|
|
657
|
+
// ff:string | undefined //font family
|
|
658
|
+
// fc:string | undefined//font color
|
|
659
|
+
// fs:number | undefined//font size
|
|
660
|
+
// cl:number | undefined//strike
|
|
661
|
+
// un:number | undefined//underline
|
|
662
|
+
// bl:number | undefined//blod
|
|
663
|
+
// it:number | undefined//italic
|
|
664
|
+
// v:string | undefined
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
if (InlineString.ff == null && cellValue.ff != null) {
|
|
668
|
+
InlineString.ff = cellValue.ff;
|
|
669
|
+
}
|
|
670
|
+
if (InlineString.fc == null && cellValue.fc != null) {
|
|
671
|
+
InlineString.fc = cellValue.fc;
|
|
672
|
+
}
|
|
673
|
+
if (InlineString.fs == null && cellValue.fs != null) {
|
|
674
|
+
InlineString.fs = cellValue.fs;
|
|
675
|
+
}
|
|
676
|
+
if (InlineString.cl == null && cellValue.cl != null) {
|
|
677
|
+
InlineString.cl = cellValue.cl;
|
|
678
|
+
}
|
|
679
|
+
if (InlineString.un == null && cellValue.un != null) {
|
|
680
|
+
InlineString.un = cellValue.un;
|
|
681
|
+
}
|
|
682
|
+
if (InlineString.bl == null && cellValue.bl != null) {
|
|
683
|
+
InlineString.bl = cellValue.bl;
|
|
684
|
+
}
|
|
685
|
+
if (InlineString.it == null && cellValue.it != null) {
|
|
686
|
+
InlineString.it = cellValue.it;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
styles.push(InlineString);
|
|
690
|
+
});
|
|
691
|
+
let cellFormat = cellValue.ct;
|
|
692
|
+
if (cellFormat == null) {
|
|
693
|
+
cellFormat = new FortuneSheetCellFormat();
|
|
694
|
+
}
|
|
695
|
+
cellFormat.t = "inlineStr";
|
|
696
|
+
cellFormat.s = styles;
|
|
697
|
+
cellValue.ct = cellFormat;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
// to be confirmed
|
|
701
|
+
else if (t == ST_CellType["InlineString"] && v != null) {
|
|
702
|
+
cellValue.v = "'" + value;
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
value = escapeCharacter(value);
|
|
706
|
+
cellValue.v = value;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
if (quotePrefix != null) {
|
|
710
|
+
cellValue.qp = parseInt(quotePrefix);
|
|
711
|
+
}
|
|
712
|
+
return cellValue;
|
|
713
|
+
}
|
|
714
|
+
replaceSpecialWrap(text) {
|
|
715
|
+
text = text
|
|
716
|
+
.replace(/_x000D_/g, "")
|
|
717
|
+
.replace(/ /g, "\r\n")
|
|
718
|
+
.replace(/ /g, "\r")
|
|
719
|
+
.replace(/ /g, "\n");
|
|
720
|
+
return text;
|
|
721
|
+
}
|
|
722
|
+
getBackgroundByFill(fill, clrScheme) {
|
|
723
|
+
let patternFills = fill.getInnerElements("patternFill");
|
|
724
|
+
if (patternFills != null) {
|
|
725
|
+
let patternFill = patternFills[0];
|
|
726
|
+
let fgColors = patternFill.getInnerElements("fgColor");
|
|
727
|
+
let bgColors = patternFill.getInnerElements("bgColor");
|
|
728
|
+
let fg, bg;
|
|
729
|
+
if (fgColors != null) {
|
|
730
|
+
let fgColor = fgColors[0];
|
|
731
|
+
fg = getColor(fgColor, this.styles);
|
|
732
|
+
}
|
|
733
|
+
if (bgColors != null) {
|
|
734
|
+
let bgColor = bgColors[0];
|
|
735
|
+
bg = getColor(bgColor, this.styles);
|
|
736
|
+
}
|
|
737
|
+
// console.log(fgColors,bgColors,clrScheme);
|
|
738
|
+
if (fg != null) {
|
|
739
|
+
return fg;
|
|
740
|
+
}
|
|
741
|
+
else if (bg != null) {
|
|
742
|
+
return bg;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
let gradientfills = fill.getInnerElements("gradientFill");
|
|
747
|
+
if (gradientfills != null) {
|
|
748
|
+
//graient color fill handler
|
|
749
|
+
return null;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
getBorderInfo(borders) {
|
|
754
|
+
if (borders == null) {
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
let border = borders[0], attrList = border.attributeList;
|
|
758
|
+
let clrScheme = this.styles["clrScheme"];
|
|
759
|
+
let style = attrList.style;
|
|
760
|
+
if (style == null || style == "none") {
|
|
761
|
+
return null;
|
|
762
|
+
}
|
|
763
|
+
let colors = border.getInnerElements("color");
|
|
764
|
+
let colorRet = "#000000";
|
|
765
|
+
if (colors != null) {
|
|
766
|
+
let color = colors[0];
|
|
767
|
+
colorRet = getColor(color, this.styles, "b");
|
|
768
|
+
if (colorRet == null) {
|
|
769
|
+
colorRet = "#000000";
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
let ret = new FortuneSheetborderInfoCellValueStyle();
|
|
773
|
+
ret.style = borderTypes[style];
|
|
774
|
+
ret.color = colorRet;
|
|
775
|
+
return ret;
|
|
776
|
+
}
|
|
777
|
+
htmlDecode(str) {
|
|
778
|
+
return str.replace(/&#(x)?([^&]{1,5});/g, function ($, $1, $2) {
|
|
779
|
+
return String.fromCharCode(parseInt($2, $1 ? 16 : 10));
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|