本帖最后由 Richard.Huang 于 2023-8-7 12:26 编辑
您好,我想您可以通过spread.fromJSON()方法来实现您的需求:
您可以参考这篇帖子实现loading页面覆盖的原理是实现您的回调:https://gcdn.grapecity.com.cn/showtopic-98339-1-1.html
核心代码:
spread.fromJSON(workbookObj, {
incrementalLoading: {
loading: function (progress) {
console.log("正在加载");
},
loaded: function () {
console.log("加载完成");
},
},
});
也可以用spread.import()方法来实现加载成功和失败的函数回调,您可以查看API:https://demo.grapecity.com.cn/sp ... ets.Workbook#import
核心代码:
document.getElementById('loadFile').onclick = function () {
const startTime = new Date().getTime(); // 记录导入开始时间
var file = document.getElementById("fileDemo").files[0];
spread.import(file, function () {
const endTime = new Date().getTime(); // 记录导入结束时间
const timeElapsed = (endTime - startTime) / 1000; // 计算时间差(以秒为单位)
alert(`导入文件 "${file.name}" 耗时:${timeElapsed}秒`);
}, function (e) {
console.log(e); // 失败回调函数
}, {
openMode: 0; // 加载模式,枚举值,0为普通,1为懒加载,2为增量加载
});
}
|