原因在于suspend的时候每次会叠一层, resume的时候每次也只会解一层, 来回切sheet会导致suspend多层, 而设置的cellChanged的resume只会解掉一层, 使用以下代码可以解决这个问题
- spread.options.calcOnDemand = true;
- let suspendMap = {};
- spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanged, function (e, args) {
- let sheet = spread.getSheetFromName(args.newSheet.name()+"");
- if (!suspendMap[sheet.name()]) {
- sheet.suspendCalcService();
- suspendMap[sheet.name()] = true;
- }
- });
- spread.bind(GC.Spread.Sheets.Events.CellChanged, function (e, info) {
- let sheet = spread.getActiveSheet();
- sheet.resumeCalcService(true);
- suspendMap[sheet.name()] = false;
- });
复制代码 |