-
Notifications
You must be signed in to change notification settings - Fork 8
/
luckyexcel.esm.js
4310 lines (4293 loc) · 171 KB
/
luckyexcel.esm.js
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import JSZip from 'jszip';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
var columeHeader_word_index = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25 };
var coreFile = "docProps/core.xml";
var appFile = "docProps/app.xml";
var workBookFile = "xl/workbook.xml";
var calcChainFile = "xl/calcChain.xml";
var stylesFile = "xl/styles.xml";
var sharedStringsFile = "xl/sharedStrings.xml";
var theme1File = "xl/theme/theme1.xml";
var workbookRels = "xl/_rels/workbook.xml.rels";
//Excel Built-In cell type
var ST_CellType = {
"Boolean": "b",
"Date": "d",
"Error": "e",
"InlineString": "inlineStr",
"Number": "n",
"SharedString": "s",
"String": "str",
};
var numFmtDefault = {
"0": 'General',
"1": '0',
"2": '0.00',
"3": '#,##0',
"4": '#,##0.00',
"9": '0%',
"10": '0.00%',
"11": '0.00E+00',
"12": '# ?/?',
"13": '# ??/??',
"14": 'm/d/yy',
"15": 'd-mmm-yy',
"16": 'd-mmm',
"17": 'mmm-yy',
"18": 'h:mm AM/PM',
"19": 'h:mm:ss AM/PM',
"20": 'h:mm',
"21": 'h:mm:ss',
"22": 'm/d/yy h:mm',
"37": '#,##0 ;(#,##0)',
"38": '#,##0 ;[Red](#,##0)',
"39": '#,##0.00;(#,##0.00)',
"40": '#,##0.00;[Red](#,##0.00)',
"45": 'mm:ss',
"46": '[h]:mm:ss',
"47": 'mmss.0',
"48": '##0.0E+0',
"49": '@'
};
var indexedColors = {
"0": '00000000',
"1": '00FFFFFF',
"2": '00FF0000',
"3": '0000FF00',
"4": '000000FF',
"5": '00FFFF00',
"6": '00FF00FF',
"7": '0000FFFF',
"8": '00000000',
"9": '00FFFFFF',
"10": '00FF0000',
"11": '0000FF00',
"12": '000000FF',
"13": '00FFFF00',
"14": '00FF00FF',
"15": '0000FFFF',
"16": '00800000',
"17": '00008000',
"18": '00000080',
"19": '00808000',
"20": '00800080',
"21": '00008080',
"22": '00C0C0C0',
"23": '00808080',
"24": '009999FF',
"25": '00993366',
"26": '00FFFFCC',
"27": '00CCFFFF',
"28": '00660066',
"29": '00FF8080',
"30": '000066CC',
"31": '00CCCCFF',
"32": '00000080',
"33": '00FF00FF',
"34": '00FFFF00',
"35": '0000FFFF',
"36": '00800080',
"37": '00800000',
"38": '00008080',
"39": '000000FF',
"40": '0000CCFF',
"41": '00CCFFFF',
"42": '00CCFFCC',
"43": '00FFFF99',
"44": '0099CCFF',
"45": '00FF99CC',
"46": '00CC99FF',
"47": '00FFCC99',
"48": '003366FF',
"49": '0033CCCC',
"50": '0099CC00',
"51": '00FFCC00',
"52": '00FF9900',
"53": '00FF6600',
"54": '00666699',
"55": '00969696',
"56": '00003366',
"57": '00339966',
"58": '00003300',
"59": '00333300',
"60": '00993300',
"61": '00993366',
"62": '00333399',
"63": '00333333',
"64": null,
"65": null,
};
var borderTypes = {
"none": 0,
"thin": 1,
"hair": 2,
"dotted": 3,
"dashed": 4,
"dashDot": 5,
"dashDotDot": 6,
"double": 7,
"medium": 8,
"mediumDashed": 9,
"mediumDashDot": 10,
"mediumDashDotDot": 11,
"slantDashDot": 12,
"thick": 13
};
var fontFamilys = {
"0": "defualt",
"1": "Roman",
"2": "Swiss",
"3": "Modern",
"4": "Script",
"5": "Decorative"
};
function getcellrange(txt, sheets, sheetId) {
if (sheets === void 0) { sheets = {}; }
if (sheetId === void 0) { sheetId = "1"; }
var val = txt.split("!");
var sheettxt = "", rangetxt = "", sheetIndex = -1;
if (val.length > 1) {
sheettxt = val[0];
rangetxt = val[1];
var si = sheets[sheettxt];
if (si == null) {
sheetIndex = parseInt(sheetId);
}
else {
sheetIndex = parseInt(si);
}
}
else {
sheetIndex = parseInt(sheetId);
rangetxt = val[0];
}
if (rangetxt.indexOf(":") == -1) {
var row = parseInt(rangetxt.replace(/[^0-9]/g, "")) - 1;
var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
if (!isNaN(row) && !isNaN(col)) {
return {
"row": [row, row],
"column": [col, col],
"sheetIndex": sheetIndex
};
}
else {
return null;
}
}
else {
var rangetxtArray = rangetxt.split(":");
var row = [], col = [];
row[0] = parseInt(rangetxtArray[0].replace(/[^0-9]/g, "")) - 1;
row[1] = parseInt(rangetxtArray[1].replace(/[^0-9]/g, "")) - 1;
// if (isNaN(row[0])) {
// row[0] = 0;
// }
// if (isNaN(row[1])) {
// row[1] = sheetdata.length - 1;
// }
if (row[0] > row[1]) {
return null;
}
col[0] = ABCatNum(rangetxtArray[0].replace(/[^A-Za-z]/g, ""));
col[1] = ABCatNum(rangetxtArray[1].replace(/[^A-Za-z]/g, ""));
// if (isNaN(col[0])) {
// col[0] = 0;
// }
// if (isNaN(col[1])) {
// col[1] = sheetdata[0].length - 1;
// }
if (col[0] > col[1]) {
return null;
}
return {
"row": row,
"column": col,
"sheetIndex": sheetIndex
};
}
}
//列下标 字母转数字
function ABCatNum(abc) {
abc = abc.toUpperCase();
var abc_len = abc.length;
if (abc_len == 0) {
return NaN;
}
var abc_array = abc.split("");
var wordlen = columeHeader_word.length;
var ret = 0;
for (var i = abc_len - 1; i >= 0; i--) {
if (i == abc_len - 1) {
ret += columeHeader_word_index[abc_array[i]];
}
else {
ret += Math.pow(wordlen, abc_len - i - 1) * (columeHeader_word_index[abc_array[i]] + 1);
}
}
return ret;
}
//列下标 数字转字母
function chatatABC(index) {
var wordlen = columeHeader_word.length;
if (index < wordlen) {
return columeHeader_word[index];
}
else {
var last = 0, ret = "";
var i = 1, n = 0;
while (index >= (wordlen / (wordlen - 1)) * (Math.pow(wordlen, i++) - 1)) {
n = i;
}
var index_ab = index - (wordlen / (wordlen - 1)) * (Math.pow(wordlen, n - 1) - 1); //970
last = index_ab + 1;
for (var x = n; x > 0; x--) {
var last1 = last; //-702=268, 3
if (x == 1) {
last1 = last1 % wordlen;
if (last1 == 0) {
last1 = 26;
}
return ret + columeHeader_word[last1 - 1];
}
last1 = Math.ceil(last1 / Math.pow(wordlen, x - 1));
//last1 = last1 % wordlen;
ret += columeHeader_word[last1 - 1];
if (x > 1) {
last = last - (last1 - 1) * wordlen;
}
}
}
}
/**
* @return ratio, default 0.75 1in = 2.54cm = 25.4mm = 72pt = 6pc, pt = 1/72 In, px = 1/dpi In
*/
function getptToPxRatioByDPI() {
return 72 / 96;
}
/**
* @emus EMUs, Excel drawing unit
* @return pixel
*/
function getPxByEMUs(emus) {
if (emus == null) {
return 0;
}
var inch = emus / 914400;
var pt = inch * 72;
var px = pt / getptToPxRatioByDPI();
return px;
}
/**
* @dom xml attribute object
* @attr attribute name
* @d if attribute is null, return default value
* @return attribute value
*/
function getXmlAttibute(dom, attr, d) {
var value = dom[attr];
value = value == null ? d : value;
return value;
}
/**
* @columnWidth Excel column width
* @return pixel column width
*/
function getColumnWidthPixel(columnWidth) {
var pix = Math.round((columnWidth - 0.83) * 8 + 5);
return pix;
}
/**
* @rowHeight Excel row height
* @return pixel row height
*/
function getRowHeightPixel(rowHeight) {
var pix = Math.round(rowHeight / getptToPxRatioByDPI());
return pix;
}
function LightenDarkenColor(sixColor, tint) {
var hex = sixColor.substring(sixColor.length - 6, sixColor.length);
var rgbArray = hexToRgbArray("#" + hex);
var hslArray = rgbToHsl(rgbArray[0], rgbArray[1], rgbArray[2]);
if (tint > 0) {
hslArray[2] = hslArray[2] * (1.0 - tint) + tint;
}
else if (tint < 0) {
hslArray[2] = hslArray[2] * (1.0 + tint);
}
else {
return "#" + hex;
}
var newRgbArray = hslToRgb(hslArray[0], hslArray[1], hslArray[2]);
return rgbToHex("RGB(" + newRgbArray.join(",") + ")");
}
function rgbToHex(rgb) {
//十六进制颜色值的正则表达式
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
// 如果是rgb颜色表示
if (/^(rgb|RGB)/.test(rgb)) {
var aColor = rgb.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
var strHex = "#";
for (var i = 0; i < aColor.length; i++) {
var hex = Number(aColor[i]).toString(16);
if (hex.length < 2) {
hex = '0' + hex;
}
strHex += hex;
}
if (strHex.length !== 7) {
strHex = rgb;
}
return strHex;
}
else if (reg.test(rgb)) {
var aNum = rgb.replace(/#/, "").split("");
if (aNum.length === 6) {
return rgb;
}
else if (aNum.length === 3) {
var numHex = "#";
for (var i = 0; i < aNum.length; i += 1) {
numHex += (aNum[i] + aNum[i]);
}
return numHex;
}
}
return rgb;
}
function hexToRgbArray(hex) {
var sColor = hex.toLowerCase();
//十六进制颜色值的正则表达式
var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
// 如果是16进制颜色
if (sColor && reg.test(sColor)) {
if (sColor.length === 4) {
var sColorNew = "#";
for (var i = 1; i < 4; i += 1) {
sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1));
}
sColor = sColorNew;
}
//处理六位的颜色值
var sColorChange = [];
for (var i = 1; i < 7; i += 2) {
sColorChange.push(parseInt("0x" + sColor.slice(i, i + 2)));
}
return sColorChange;
}
return null;
}
/**
* HSL颜色值转换为RGB.
* 换算公式改编自 http://en.wikipedia.org/wiki/HSL_color_space.
* h, s, 和 l 设定在 [0, 1] 之间
* 返回的 r, g, 和 b 在 [0, 255]之间
*
* @param Number h 色相
* @param Number s 饱和度
* @param Number l 亮度
* @return Array RGB色值数值
*/
function hslToRgb(h, s, l) {
var r, g, b;
if (s == 0) {
r = g = b = l; // achromatic
}
else {
var hue2rgb = function hue2rgb(p, q, t) {
if (t < 0)
t += 1;
if (t > 1)
t -= 1;
if (t < 1 / 6)
return p + (q - p) * 6 * t;
if (t < 1 / 2)
return q;
if (t < 2 / 3)
return p + (q - p) * (2 / 3 - t) * 6;
return p;
};
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1 / 3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1 / 3);
}
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
}
/**
* RGB 颜色值转换为 HSL.
* 转换公式参考自 http://en.wikipedia.org/wiki/HSL_color_space.
* r, g, 和 b 需要在 [0, 255] 范围内
* 返回的 h, s, 和 l 在 [0, 1] 之间
*
* @param Number r 红色色值
* @param Number g 绿色色值
* @param Number b 蓝色色值
* @return Array HSL各值数组
*/
function rgbToHsl(r, g, b) {
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if (max == min) {
h = s = 0; // achromatic
}
else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r:
h = (g - b) / d + (g < b ? 6 : 0);
break;
case g:
h = (b - r) / d + 2;
break;
case b:
h = (r - g) / d + 4;
break;
}
h /= 6;
}
return [h, s, l];
}
function generateRandomIndex(prefix) {
if (prefix == null) {
prefix = "Sheet";
}
var userAgent = window.navigator.userAgent.replace(/[^a-zA-Z0-9]/g, "").split("");
var mid = "";
for (var i = 0; i < 5; i++) {
mid += userAgent[Math.round(Math.random() * (userAgent.length - 1))];
}
var time = new Date().getTime();
return prefix + "_" + mid + "_" + time;
}
function escapeCharacter(str) {
if (str == null || str.length == 0) {
return str;
}
return str.replace(/&/g, "&").replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>').replace(/ /g, ' ').replace(/'/g, "'").replace(/¡/g, "¡").replace(/¢/g, "¢").replace(/£/g, "£").replace(/¤/g, "¤").replace(/¥/g, "¥").replace(/¦/g, "¦").replace(/§/g, "§").replace(/¨/g, "¨").replace(/©/g, "©").replace(/ª/g, "ª").replace(/«/g, "«").replace(/¬/g, "¬").replace(/­/g, "").replace(/®/g, "®").replace(/¯/g, "¯").replace(/°/g, "°").replace(/±/g, "±").replace(/²/g, "²").replace(/³/g, "³").replace(/´/g, "´").replace(/µ/g, "µ").replace(/¶/g, "¶").replace(/·/g, "·").replace(/¸/g, "¸").replace(/¹/g, "¹").replace(/º/g, "º").replace(/»/g, "»").replace(/¼/g, "¼").replace(/½/g, "½").replace(/¾/g, "¾").replace(/¿/g, "¿").replace(/×/g, "×").replace(/÷/g, "÷").replace(/À/g, "À").replace(/Á/g, "Á").replace(/Â/g, "Â").replace(/Ã/g, "Ã").replace(/Ä/g, "Ä").replace(/Å/g, "Å").replace(/Æ/g, "Æ").replace(/Ç/g, "Ç").replace(/È/g, "È").replace(/É/g, "É").replace(/Ê/g, "Ê").replace(/Ë/g, "Ë").replace(/Ì/g, "Ì").replace(/Í/g, "Í").replace(/Î/g, "Î").replace(/Ï/g, "Ï").replace(/Ð/g, "Ð").replace(/Ñ/g, "Ñ").replace(/Ò/g, "Ò").replace(/Ó/g, "Ó").replace(/Ô/g, "Ô").replace(/Õ/g, "Õ").replace(/Ö/g, "Ö").replace(/Ø/g, "Ø").replace(/Ù/g, "Ù").replace(/Ú/g, "Ú").replace(/Û/g, "Û").replace(/Ü/g, "Ü").replace(/Ý/g, "Ý").replace(/Þ/g, "Þ").replace(/ß/g, "ß").replace(/à/g, "à").replace(/á/g, "á").replace(/â/g, "â").replace(/ã/g, "ã").replace(/ä/g, "ä").replace(/å/g, "å").replace(/æ/g, "æ").replace(/ç/g, "ç").replace(/è/g, "è").replace(/é/g, "é").replace(/ê/g, "ê").replace(/ë/g, "ë").replace(/ì/g, "ì").replace(/í/g, "í").replace(/î/g, "î").replace(/ï/g, "ï").replace(/ð/g, "ð").replace(/ñ/g, "ñ").replace(/ò/g, "ò").replace(/ó/g, "ó").replace(/ô/g, "ô").replace(/õ/g, "õ").replace(/ö/g, "ö").replace(/ø/g, "ø").replace(/ù/g, "ù").replace(/ú/g, "ú").replace(/û/g, "û").replace(/ü/g, "ü").replace(/ý/g, "ý").replace(/þ/g, "þ").replace(/ÿ/g, "ÿ");
}
var fromulaRef = /** @class */ (function () {
function fromulaRef() {
}
fromulaRef.trim = function (str) {
if (str == null) {
str = "";
}
return str.replace(/(^\s*)|(\s*$)/g, "");
};
fromulaRef.functionCopy = function (txt, mode, step) {
var _this = this;
if (_this.operatorjson == null) {
var arr = _this.operator.split("|"), op = {};
for (var i_1 = 0; i_1 < arr.length; i_1++) {
op[arr[i_1].toString()] = 1;
}
_this.operatorjson = op;
}
if (mode == null) {
mode = "down";
}
if (step == null) {
step = 1;
}
if (txt.substr(0, 1) == "=") {
txt = txt.substr(1);
}
var funcstack = txt.split("");
var i = 0, str = "", function_str = "";
var matchConfig = {
"bracket": 0,
"comma": 0,
"squote": 0,
"dquote": 0
};
while (i < funcstack.length) {
var s = funcstack[i];
if (s == "(" && matchConfig.dquote == 0) {
matchConfig.bracket += 1;
if (str.length > 0) {
function_str += str + "(";
}
else {
function_str += "(";
}
str = "";
}
else if (s == ")" && matchConfig.dquote == 0) {
matchConfig.bracket -= 1;
function_str += _this.functionCopy(str, mode, step) + ")";
str = "";
}
else if (s == '"' && matchConfig.squote == 0) {
if (matchConfig.dquote > 0) {
function_str += str + '"';
matchConfig.dquote -= 1;
str = "";
}
else {
matchConfig.dquote += 1;
str += '"';
}
}
else if (s == ',' && matchConfig.dquote == 0) {
function_str += _this.functionCopy(str, mode, step) + ',';
str = "";
}
else if (s == '&' && matchConfig.dquote == 0) {
if (str.length > 0) {
function_str += _this.functionCopy(str, mode, step) + "&";
str = "";
}
else {
function_str += "&";
}
}
else if (s in _this.operatorjson && matchConfig.dquote == 0) {
var s_next = "";
if ((i + 1) < funcstack.length) {
s_next = funcstack[i + 1];
}
var p = i - 1, s_pre = null;
if (p >= 0) {
do {
s_pre = funcstack[p--];
} while (p >= 0 && s_pre == " ");
}
if ((s + s_next) in _this.operatorjson) {
if (str.length > 0) {
function_str += _this.functionCopy(str, mode, step) + s + s_next;
str = "";
}
else {
function_str += s + s_next;
}
i++;
}
else if (!(/[^0-9]/.test(s_next)) && s == "-" && (s_pre == "(" || s_pre == null || s_pre == "," || s_pre == " " || s_pre in _this.operatorjson)) {
str += s;
}
else {
if (str.length > 0) {
function_str += _this.functionCopy(str, mode, step) + s;
str = "";
}
else {
function_str += s;
}
}
}
else {
str += s;
}
if (i == funcstack.length - 1) {
if (_this.iscelldata(_this.trim(str))) {
if (mode == "down") {
function_str += _this.downparam(_this.trim(str), step);
}
else if (mode == "up") {
function_str += _this.upparam(_this.trim(str), step);
}
else if (mode == "left") {
function_str += _this.leftparam(_this.trim(str), step);
}
else if (mode == "right") {
function_str += _this.rightparam(_this.trim(str), step);
}
}
else {
function_str += _this.trim(str);
}
}
i++;
}
return function_str;
};
fromulaRef.downparam = function (txt, step) {
return this.updateparam("d", txt, step);
};
fromulaRef.upparam = function (txt, step) {
return this.updateparam("u", txt, step);
};
fromulaRef.leftparam = function (txt, step) {
return this.updateparam("l", txt, step);
};
fromulaRef.rightparam = function (txt, step) {
return this.updateparam("r", txt, step);
};
fromulaRef.updateparam = function (orient, txt, step) {
var _this = this;
var val = txt.split("!"), rangetxt, prefix = "";
if (val.length > 1) {
rangetxt = val[1];
prefix = val[0] + "!";
}
else {
rangetxt = val[0];
}
if (rangetxt.indexOf(":") == -1) {
var row = parseInt(rangetxt.replace(/[^0-9]/g, ""));
var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
var freezonFuc = _this.isfreezonFuc(rangetxt);
var $row = freezonFuc[0] ? "$" : "", $col = freezonFuc[1] ? "$" : "";
if (orient == "u" && !freezonFuc[0]) {
row -= step;
}
else if (orient == "r" && !freezonFuc[1]) {
col += step;
}
else if (orient == "l" && !freezonFuc[1]) {
col -= step;
}
else if (!freezonFuc[0]) {
row += step;
}
if (row < 0 || col < 0) {
return _this.error.r;
}
if (!isNaN(row) && !isNaN(col)) {
return prefix + $col + chatatABC(col) + $row + (row);
}
else if (!isNaN(row)) {
return prefix + $row + (row);
}
else if (!isNaN(col)) {
return prefix + $col + chatatABC(col);
}
else {
return txt;
}
}
else {
rangetxt = rangetxt.split(":");
var row = [], col = [];
row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, ""));
row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, ""));
if (row[0] > row[1]) {
return txt;
}
col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
if (col[0] > col[1]) {
return txt;
}
var freezonFuc0 = _this.isfreezonFuc(rangetxt[0]);
var freezonFuc1 = _this.isfreezonFuc(rangetxt[1]);
var $row0 = freezonFuc0[0] ? "$" : "", $col0 = freezonFuc0[1] ? "$" : "";
var $row1 = freezonFuc1[0] ? "$" : "", $col1 = freezonFuc1[1] ? "$" : "";
if (orient == "u") {
if (!freezonFuc0[0]) {
row[0] -= step;
}
if (!freezonFuc1[0]) {
row[1] -= step;
}
}
else if (orient == "r") {
if (!freezonFuc0[1]) {
col[0] += step;
}
if (!freezonFuc1[1]) {
col[1] += step;
}
}
else if (orient == "l") {
if (!freezonFuc0[1]) {
col[0] -= step;
}
if (!freezonFuc1[1]) {
col[1] -= step;
}
}
else {
if (!freezonFuc0[0]) {
row[0] += step;
}
if (!freezonFuc1[0]) {
row[1] += step;
}
}
if (row[0] < 0 || col[0] < 0) {
return _this.error.r;
}
if (isNaN(col[0]) && isNaN(col[1])) {
return prefix + $row0 + (row[0]) + ":" + $row1 + (row[1]);
}
else if (isNaN(row[0]) && isNaN(row[1])) {
return prefix + $col0 + chatatABC(col[0]) + ":" + $col1 + chatatABC(col[1]);
}
else {
return prefix + $col0 + chatatABC(col[0]) + $row0 + (row[0]) + ":" + $col1 + chatatABC(col[1]) + $row1 + (row[1]);
}
}
};
fromulaRef.iscelldata = function (txt) {
var val = txt.split("!"), rangetxt;
if (val.length > 1) {
rangetxt = val[1];
}
else {
rangetxt = val[0];
}
var reg_cell = /^(([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+))$/g; //增加正则判断单元格为字母+数字的格式:如 A1:B3
var reg_cellRange = /^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+))))$/g; //增加正则判断单元格为字母+数字或字母的格式:如 A1:B3,A:A
if (rangetxt.indexOf(":") == -1) {
var row = parseInt(rangetxt.replace(/[^0-9]/g, "")) - 1;
var col = ABCatNum(rangetxt.replace(/[^A-Za-z]/g, ""));
if (!isNaN(row) && !isNaN(col) && rangetxt.toString().match(reg_cell)) {
return true;
}
else if (!isNaN(row)) {
return false;
}
else if (!isNaN(col)) {
return false;
}
else {
return false;
}
}
else {
reg_cellRange = /^(((([a-zA-Z]+)|([$][a-zA-Z]+))(([0-9]+)|([$][0-9]+)))|((([a-zA-Z]+)|([$][a-zA-Z]+)))|((([0-9]+)|([$][0-9]+s))))$/g;
rangetxt = rangetxt.split(":");
var row = [], col = [];
row[0] = parseInt(rangetxt[0].replace(/[^0-9]/g, "")) - 1;
row[1] = parseInt(rangetxt[1].replace(/[^0-9]/g, "")) - 1;
if (row[0] > row[1]) {
return false;
}
col[0] = ABCatNum(rangetxt[0].replace(/[^A-Za-z]/g, ""));
col[1] = ABCatNum(rangetxt[1].replace(/[^A-Za-z]/g, ""));
if (col[0] > col[1]) {
return false;
}
if (rangetxt[0].toString().match(reg_cellRange) && rangetxt[1].toString().match(reg_cellRange)) {
return true;
}
else {
return false;
}
}
};
fromulaRef.isfreezonFuc = function (txt) {
var row = txt.replace(/[^0-9]/g, "");
var col = txt.replace(/[^A-Za-z]/g, "");
var row$ = txt.substr(txt.indexOf(row) - 1, 1);
var col$ = txt.substr(txt.indexOf(col) - 1, 1);
var ret = [false, false];
if (row$ == "$") {
ret[0] = true;
}
if (col$ == "$") {
ret[1] = true;
}
return ret;
};
fromulaRef.operator = '==|!=|<>|<=|>=|=|+|-|>|<|/|*|%|&|^';
fromulaRef.error = {
v: "#VALUE!",
n: "#NAME?",
na: "#N/A",
r: "#REF!",
d: "#DIV/0!",
nm: "#NUM!",
nl: "#NULL!",
sp: "#SPILL!" //数组范围有其它值
};
fromulaRef.operatorjson = null;
return fromulaRef;
}());
function isChinese(temp) {
var re = /[^\u4e00-\u9fa5]/;
var reg = /[\u3002|\uff1f|\uff01|\uff0c|\u3001|\uff1b|\uff1a|\u201c|\u201d|\u2018|\u2019|\uff08|\uff09|\u300a|\u300b|\u3008|\u3009|\u3010|\u3011|\u300e|\u300f|\u300c|\u300d|\ufe43|\ufe44|\u3014|\u3015|\u2026|\u2014|\uff5e|\ufe4f|\uffe5]/;
if (reg.test(temp))
return true;
if (re.test(temp))
return false;
return true;
}
function isJapanese(temp) {
var re = /[^\u0800-\u4e00]/;
if (re.test(temp))
return false;
return true;
}
function isKoera(chr) {
if (((chr > 0x3130 && chr < 0x318F) ||
(chr >= 0xAC00 && chr <= 0xD7A3))) {
return true;
}
return false;
}
function getBinaryContent(path, options) {
var promise, resolve, reject;
var callback;
if (!options) {
options = {};
}
// taken from jQuery
var createStandardXHR = function () {
try {
return new window.XMLHttpRequest();
}
catch (e) { }
};
var createActiveXHR = function () {
try {
return new window.ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) { }
};
// Create the request object
var createXHR = (typeof window !== "undefined" && window.ActiveXObject) ?
/* Microsoft failed to properly
* implement the XMLHttpRequest in IE7 (can't request local files),
* so we use the ActiveXObject when it is available
* Additionally XMLHttpRequest can be disabled in IE7/IE8 so
* we need a fallback.
*/
function () {
return createStandardXHR() || createActiveXHR();
} :
// For all other browsers, use the standard XMLHttpRequest object
createStandardXHR;
// backward compatible callback
if (typeof options === "function") {
callback = options;
options = {};
}
else if (typeof options.callback === 'function') {
// callback inside options object
callback = options.callback;
}
resolve = function (data) { callback(null, data); };
reject = function (err) { callback(err, null); };
try {
var xhr = createXHR();
xhr.open('GET', path, true);
// recent browsers
if ("responseType" in xhr) {
xhr.responseType = "arraybuffer";
}
// older browser
if (xhr.overrideMimeType) {
xhr.overrideMimeType("text/plain; charset=x-user-defined");
}
xhr.onreadystatechange = function (event) {
// use `xhr` and not `this`... thanks IE
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
try {
resolve(function (xhr) {
// for xhr.responseText, the 0xFF mask is applied by JSZip
return xhr.response || xhr.responseText;
}(xhr));
}
catch (err) {
reject(new Error(err));
}
}
else {
reject(new Error("Ajax error for " + path + " : " + this.status + " " + this.statusText));
}
}
};
if (options.progress) {
xhr.onprogress = function (e) {
options.progress({
path: path,
originalEvent: e,
percent: e.loaded / e.total * 100,
loaded: e.loaded,
total: e.total
});
};
}
xhr.send();
}
catch (e) {
reject(new Error(e), null);
}
// returns a promise or undefined depending on whether a callback was
// provided
return promise;
}
var xmloperation = /** @class */ (function () {
function xmloperation() {
}
/**
* @param tag Search xml tag name , div,title etc.
* @param file Xml string
* @return Xml element string
*/
xmloperation.prototype.getElementsByOneTag = function (tag, file) {
//<a:[^/>: ]+?>.*?</a:[^/>: ]+?>
var readTagReg;
if (tag.indexOf("|") > -1) {
var tags = tag.split("|"), tagsRegTxt = "";
for (var i = 0; i < tags.length; i++) {
var t = tags[i];
tagsRegTxt += "|<" + t + " [^>]+?[^/]>[\\s\\S]*?</" + t + ">|<" + t + " [^>]+?/>|<" + t + ">[\\s\\S]*?</" + t + ">|<" + t + "/>";
}
tagsRegTxt = tagsRegTxt.substr(1, tagsRegTxt.length);
readTagReg = new RegExp(tagsRegTxt, "g");
}
else {
readTagReg = new RegExp("<" + tag + " [^>]+?[^/]>[\\s\\S]*?</" + tag + ">|<" + tag + " [^>]+?/>|<" + tag + ">[\\s\\S]*?</" + tag + ">|<" + tag + "/>", "g");
}
var ret = file.match(readTagReg);
if (ret == null) {
return [];
}
else {
return ret;
}
};
return xmloperation;
}());
var ReadXml = /** @class */ (function (_super) {
__extends(ReadXml, _super);
function ReadXml(files) {
var _this = _super.call(this) || this;
_this.originFile = files;
return _this;
}
/**
* @param path Search xml tag group , div,title etc.
* @param fileName One of uploadfileList, uploadfileList is file group, {key:value}
* @return Xml element calss
*/
ReadXml.prototype.getElementsByTagName = function (path, fileName) {
var file = this.getFileByName(fileName);
var pathArr = path.split("/"), ret;
for (var key in pathArr) {
var path_1 = pathArr[key];
if (ret == undefined) {
ret = this.getElementsByOneTag(path_1, file);