rapid-spreadjs 1.0.21 → 1.0.23
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/index.cjs.js +49 -27
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +49 -27
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/utils/common.d.ts +6 -0
- package/dist/utils/wookbook.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,27 +3,6 @@ import * as math from 'mathjs';
|
|
|
3
3
|
import { groupByJson, forEachJson, orderByJson } from 'rapid-utils';
|
|
4
4
|
import { saveAs } from 'file-saver';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* 公用工具函数属性
|
|
8
|
-
*/
|
|
9
|
-
const CommonUtils = {
|
|
10
|
-
/**
|
|
11
|
-
* 获取列的英文字母
|
|
12
|
-
* @param colIndex 列的索引
|
|
13
|
-
* @returns 返回英文字母
|
|
14
|
-
*/
|
|
15
|
-
getColLetterName: (colIndex) => {
|
|
16
|
-
colIndex += 1;
|
|
17
|
-
let letter = "";
|
|
18
|
-
while (colIndex > 0) {
|
|
19
|
-
const remainder = (colIndex - 1) % 26;
|
|
20
|
-
letter = String.fromCharCode(remainder + 65) + letter;
|
|
21
|
-
colIndex = Math.floor((colIndex - 1) / 26);
|
|
22
|
-
}
|
|
23
|
-
return letter.toUpperCase();
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
6
|
/******************************************************************************
|
|
28
7
|
Copyright (c) Microsoft Corporation.
|
|
29
8
|
|
|
@@ -56,6 +35,45 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
56
35
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
36
|
};
|
|
58
37
|
|
|
38
|
+
/**
|
|
39
|
+
* 公用工具函数属性
|
|
40
|
+
*/
|
|
41
|
+
const CommonUtils = {
|
|
42
|
+
/**
|
|
43
|
+
* 获取文件的字节流对象
|
|
44
|
+
* @param fileUrl 在线文件地址
|
|
45
|
+
* @returns 文件的字节流对象
|
|
46
|
+
*/
|
|
47
|
+
getFileBlob: (fileUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
// 获取文件响应结果
|
|
49
|
+
const response = yield fetch(fileUrl, { method: 'GET' });
|
|
50
|
+
// 获取成功
|
|
51
|
+
if (response.ok) {
|
|
52
|
+
// 文件的字节流对象
|
|
53
|
+
const blob = yield response.blob();
|
|
54
|
+
return blob;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
60
|
+
/**
|
|
61
|
+
* 获取列的英文字母
|
|
62
|
+
* @param colIndex 列的索引
|
|
63
|
+
* @returns 返回英文字母
|
|
64
|
+
*/
|
|
65
|
+
getColLetterName: (colIndex) => {
|
|
66
|
+
colIndex += 1;
|
|
67
|
+
let letter = '';
|
|
68
|
+
while (colIndex > 0) {
|
|
69
|
+
const remainder = (colIndex - 1) % 26;
|
|
70
|
+
letter = String.fromCharCode(remainder + 65) + letter;
|
|
71
|
+
colIndex = Math.floor((colIndex - 1) / 26);
|
|
72
|
+
}
|
|
73
|
+
return letter.toUpperCase();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
59
77
|
/**
|
|
60
78
|
* 公用方法,如:修约计算等
|
|
61
79
|
*/
|
|
@@ -7765,18 +7783,22 @@ const WorkbookUtils = {
|
|
|
7765
7783
|
// 文件的字节流对象
|
|
7766
7784
|
const blob = yield response.blob();
|
|
7767
7785
|
// 将Blob转换为File或Blob对象
|
|
7768
|
-
new File([blob], 'template.sjs', { type: 'application/octet-stream' });
|
|
7786
|
+
// const file = new File([blob], 'template.sjs', { type: 'application/octet-stream' });
|
|
7769
7787
|
const sjsBlob = new Blob([blob], { type: 'application/zip' });
|
|
7770
7788
|
// SpreadJS打开文件
|
|
7771
|
-
spread.open(sjsBlob, () => {
|
|
7789
|
+
spread.open(sjsBlob, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
7772
7790
|
if (typeof succFunc === 'function') {
|
|
7773
|
-
succFunc(spread);
|
|
7791
|
+
yield succFunc(spread);
|
|
7792
|
+
// // 或者使用then回调
|
|
7793
|
+
// succFunc(spread).then((ret) => {
|
|
7794
|
+
// // return ret;
|
|
7795
|
+
// });
|
|
7774
7796
|
}
|
|
7775
|
-
}, (e) => {
|
|
7797
|
+
}), (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7776
7798
|
if (typeof errorFunc === 'function') {
|
|
7777
|
-
errorFunc(e);
|
|
7799
|
+
yield errorFunc(e);
|
|
7778
7800
|
}
|
|
7779
|
-
});
|
|
7801
|
+
}));
|
|
7780
7802
|
}
|
|
7781
7803
|
}),
|
|
7782
7804
|
/**
|