rapid-spreadjs 1.0.18 → 1.0.19
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 +33 -16
- 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 +33 -16
- 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/wookbook.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -7677,11 +7677,39 @@ const SheetUtils = {
|
|
|
7677
7677
|
},
|
|
7678
7678
|
};
|
|
7679
7679
|
|
|
7680
|
-
// 导出Excel文件所需的第三方包
|
|
7681
7680
|
/**
|
|
7682
7681
|
* SpreadJS工作簿工具函数属性
|
|
7683
7682
|
*/
|
|
7684
7683
|
const WorkbookUtils = {
|
|
7684
|
+
/**
|
|
7685
|
+
* 加载在线sjs文件
|
|
7686
|
+
* @param spread 工作簿对象
|
|
7687
|
+
* @param fileUrl 在线sjs文件地址
|
|
7688
|
+
* @param succFunc 文件打开成功后的回调函数,返回的第一个参数为spread工作簿对象
|
|
7689
|
+
* @param errorFunc 文件打开失败后的回调函数,返回的第一个参数为错误信息
|
|
7690
|
+
*/
|
|
7691
|
+
loadSjsFile: (spread, fileUrl, succFunc, errorFunc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7692
|
+
// 获取文件响应结果
|
|
7693
|
+
const response = yield fetch(fileUrl, { method: 'GET' });
|
|
7694
|
+
// 获取成功
|
|
7695
|
+
if (response.ok) {
|
|
7696
|
+
// 文件的字节流对象
|
|
7697
|
+
const blob = yield response.blob();
|
|
7698
|
+
// 将Blob转换为File或Blob对象
|
|
7699
|
+
new File([blob], 'template.sjs', { type: 'application/octet-stream' });
|
|
7700
|
+
const sjsBlob = new Blob([blob], { type: 'application/zip' });
|
|
7701
|
+
// SpreadJS打开文件
|
|
7702
|
+
spread.open(sjsBlob, () => {
|
|
7703
|
+
if (typeof succFunc === 'function') {
|
|
7704
|
+
succFunc(spread);
|
|
7705
|
+
}
|
|
7706
|
+
}, (e) => {
|
|
7707
|
+
if (typeof errorFunc === 'function') {
|
|
7708
|
+
errorFunc(e);
|
|
7709
|
+
}
|
|
7710
|
+
});
|
|
7711
|
+
}
|
|
7712
|
+
}),
|
|
7685
7713
|
/**
|
|
7686
7714
|
* 打印所有工作表
|
|
7687
7715
|
* @param GC GC对象
|
|
@@ -7748,20 +7776,11 @@ const WorkbookUtils = {
|
|
|
7748
7776
|
* @param spread 原始Spread对象
|
|
7749
7777
|
* @param fileName 导出的文件名称,不传则为第一个工作表的名称
|
|
7750
7778
|
*/
|
|
7751
|
-
exportToExcel: (GC, spread, fileName =
|
|
7779
|
+
exportToExcel: (GC, spread, fileName = '') => {
|
|
7752
7780
|
// 导出模板为JSON对象,此处设置了参数includeBindingSource,改参数代表包含数据绑定的值
|
|
7753
7781
|
const json = spread.toJSON({ includeBindingSource: true });
|
|
7754
7782
|
// 需要移除的自定义公式名称集合(该变量的作用是,在导出Excel前,将工作簿中所有的自定义公式移除掉,其他内置的公式保留)
|
|
7755
|
-
const removeCustomFormulas = [
|
|
7756
|
-
"YJMAX",
|
|
7757
|
-
"YJMIN",
|
|
7758
|
-
"YJMID",
|
|
7759
|
-
"YJGETNUM",
|
|
7760
|
-
"YJGETS",
|
|
7761
|
-
"YJGETCV",
|
|
7762
|
-
"YJINTERPOLATIONMETHOD",
|
|
7763
|
-
"YJINTERPOLATIONMETHOD_Y",
|
|
7764
|
-
];
|
|
7783
|
+
const removeCustomFormulas = ['YJMAX', 'YJMIN', 'YJMID', 'YJGETNUM', 'YJGETS', 'YJGETCV', 'YJINTERPOLATIONMETHOD', 'YJINTERPOLATIONMETHOD_Y'];
|
|
7765
7784
|
// 临时工作簿
|
|
7766
7785
|
const tempSpread = new GC.Spread.Sheets.Workbook();
|
|
7767
7786
|
tempSpread.fromJSON(json);
|
|
@@ -7779,9 +7798,7 @@ const WorkbookUtils = {
|
|
|
7779
7798
|
// 获取单元格的公式
|
|
7780
7799
|
const cellFormula = sheet.getFormula(i, j);
|
|
7781
7800
|
// 如果cellFormula不为null或undefined,则说明该单元格引用了公式
|
|
7782
|
-
if (cellFormula != null &&
|
|
7783
|
-
cellFormula != undefined &&
|
|
7784
|
-
removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
|
|
7801
|
+
if (cellFormula != null && cellFormula != undefined && removeCustomFormulas.some((item) => cellFormula.indexOf(item) > -1)) {
|
|
7785
7802
|
// 获取单元格的值
|
|
7786
7803
|
const cellVal = sheet.getValue(i, j);
|
|
7787
7804
|
// 移除单元格引用的公式
|
|
@@ -7796,7 +7813,7 @@ const WorkbookUtils = {
|
|
|
7796
7813
|
}
|
|
7797
7814
|
// 恢复绘制
|
|
7798
7815
|
tempSpread.resumePaint();
|
|
7799
|
-
if (fileName ==
|
|
7816
|
+
if (fileName == '') {
|
|
7800
7817
|
fileName = tempSpread.getSheet(0).name();
|
|
7801
7818
|
}
|
|
7802
7819
|
let options = {
|