Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(sheet): error while creating an empty subunit (#1748)

Gpound.liu662b4e0b843d
diff --git a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts
index 50c8c9cc82..0bf7bbcaf2 100644
--- a/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts
+++ b/packages/sheets-conditional-formatting/src/services/conditional-formatting.service.ts
@@ -40,7 +40,7 @@ type ComputeStatus = 'computing' | 'end' | 'error';
interface IComputeCache { status: ComputeStatus };
const beforeUpdateRuleResult = createInterceptorKey< { subUnitId: string; unitId: string; cfId: string }>('conditional-formatting-before-update-rule-result');
-@OnLifecycle(LifecycleStages.Starting, ConditionalFormattingService)
+@OnLifecycle(LifecycleStages.Ready, ConditionalFormattingService)
export class ConditionalFormattingService extends Disposable {
// <unitId,<subUnitId,<cfId,IComputeCache>>>
private _ruleCacheMap: Map<string, Map<string, Map<string, IComputeCache>>> = new Map();
@@ -162,8 +162,8 @@ export class ConditionalFormattingService extends Disposable {
})
)
);
- const workbook = this._univerInstanceService.getCurrentUniverSheetInstance();
- handleWorkbookAdd(workbook);
+ const workbookList = this._univerInstanceService.getAllUniverSheetsInstance();
+ workbookList.forEach((workbook) => handleWorkbookAdd(workbook));
}
private _initSheetChange() {