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(formula): formula update after hide row column (#4238)

Dushusir4113714af7ef
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts
new file mode 100644
index 0000000000..c8925bfc86
--- /dev/null
+++ b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts
@@ -0,0 +1,177 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { chromium, expect, test } from '@playwright/test';
+import { generateSnapshotName } from '../const';
+
+const SHEET_MAIN_CANVAS_ID = '[id^="univer-sheet-main-canvas_"]';
+const isCI = !!process.env.CI;
+
+test('diff formula related', async () => {
+ const browser = await chromium.launch({
+ headless: !!isCI, // Set to false to see the browser window
+ });
+ const context = await browser.newContext({
+ viewport: { width: 1280, height: 1280 },
+ deviceScaleFactor: 2, // Set your desired DPR
+ });
+ const page = await context.newPage();
+ await page.goto('http://localhost:3000/sheets/');
+ await page.waitForTimeout(2000);
+ await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet());
+ await page.waitForTimeout(5000);
+
+ await page.evaluate(async () => {
+ const worksheet = window.univerAPI.getActiveWorkbook().create('formula', 50, 20);
+ worksheet.getRange('A1:C6').setValues({
+ 0: {
+ 0: {
+ v: 1,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ 1: {
+ v: 1,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ },
+ 1: {
+ 0: {
+ v: 2,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ 1: {
+ v: 2,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ },
+ 2: {
+ 0: {
+ v: 3,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ 1: {
+ v: 3,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ },
+ 3: {
+ 0: {
+ v: 4,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ 1: {
+ v: 4,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ },
+ 4: {
+ 0: {
+ v: 5,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ 1: {
+ v: 5,
+ t: 2,
+ s: 'cYigQ9',
+ },
+ },
+ 5: {
+ 0: {
+ f: '=SUBTOTAL(109,A1:A5)',
+ v: 15,
+ t: 2,
+ },
+ 1: {
+ f: '=SUBTOTAL(109,B1:B5)',
+ v: 15,
+ t: 2,
+ },
+ 2: {
+ f: '=SUM(B1:B5)',
+ v: 15,
+ t: 2,
+ },
+ },
+ });
+
+ const worksheet2 = window.univerAPI.getActiveWorkbook().create('formula2', 50, 20);
+ worksheet2.getRange('A1').setValue({ f: '=SUBTOTAL(109,formula!B1:B5)' });
+ });
+
+ // The impact of hide row on the formula of the current worksheet
+ await page.evaluate(async () => {
+ const worksheet = window.univerAPI.getActiveWorkbook().getSheetByName('formula');
+ window.univerAPI.getActiveWorkbook().setActiveSheet(worksheet);
+ await worksheet.hideRows(3, 2);
+ });
+
+ await page.waitForTimeout(100);
+
+ const filename1 = generateSnapshotName('formula-hide-row-current-worksheet');
+ const screenshot1 = await page.locator(SHEET_MAIN_CANVAS_ID).screenshot();
+ await expect(screenshot1).toMatchSnapshot(filename1, { maxDiffPixels: 7 });
+
+ // restore the hidden row
+ await page.evaluate(async () => {
+ const worksheet = window.univerAPI.getActiveWorkbook().getActiveSheet();
+ await worksheet.showRows(3, 2);
+ });
+
+ // The impact of filtering on the formula of the current worksheet
+ await page.evaluate(async () => {
+ const worksheet = window.univerAPI.getActiveWorkbook().getActiveSheet();
+ const filter = await worksheet.getRange('A1:A5').createFilter();
+ await filter.setColumnFilterCriteria(0, {
+ colId: 0,
+ filters: {
+ filters: [
+ '5',
+ '4',
+ '2',
+ ],
+ },
+ });
+ });
+
+ await page.waitForTimeout(100);
+
+ const filename2 = generateSnapshotName('formula-filter-row-current-worksheet');
+ const screenshot2 = await page.locator(SHEET_MAIN_CANVAS_ID).screenshot();
+ await expect(screenshot2).toMatchSnapshot(filename2, { maxDiffPixels: 7 });
+
+ await page.evaluate(async () => {
+ const worksheet2 = window.univerAPI.getActiveWorkbook().getSheetByName('formula2');
+ window.univerAPI.getActiveWorkbook().setActiveSheet(worksheet2);
+ });
+
+ await page.waitForTimeout(100);
+
+ const filename3 = generateSnapshotName('formula-filter-row-other-worksheet');
+ const screenshot3 = await page.locator(SHEET_MAIN_CANVAS_ID).screenshot();
+ await expect(screenshot3).toMatchSnapshot(filename3, { maxDiffPixels: 11 });
+
+ await page.waitForTimeout(1000);
+ await browser.close();
+});
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-chromium-linux.png
new file mode 100644
index 0000000000..9d49875a9a
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png
new file mode 100644
index 0000000000..fd52d05fd7
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-current-worksheet-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-chromium-linux.png
new file mode 100644
index 0000000000..f554571052
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png
new file mode 100644
index 0000000000..1d0892d0f6
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-filter-row-other-worksheet-ci-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-chromium-linux.png
new file mode 100644
index 0000000000..4d2d439a18
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-chromium-linux.png differ
diff --git a/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png
new file mode 100644
index 0000000000..81bc8b65e1
Binary files /dev/null and b/e2e/visual-comparison/sheets/sheets-formula-related.spec.ts-snapshots/formula-hide-row-current-worksheet-ci-chromium-linux.png differ
diff --git a/packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts b/packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts
index a15a8016ea..f11f2ea074 100644
--- a/packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts
+++ b/packages-experimental/debugger/src/controllers/e2e/e2e.controller.ts
@@ -68,7 +68,7 @@ export class E2EController extends Disposable {
loadDemoSheet: () => this._loadDemoSheet(),
loadMergeCellSheet: () => this._loadMergeCellSheet(2000),
loadDefaultStyleSheet: (loadTimeout) => this._loadDefaultStyleSheet(loadTimeout),
- disposeCurrSheetUnit: (disposeTimeout?: number) => this._diposeDefaultSheetUnit(disposeTimeout),
+ disposeCurrSheetUnit: (disposeTimeout?: number) => this._disposeDefaultSheetUnit(disposeTimeout),
loadDefaultDoc: (loadTimeout) => this._loadDefaultDoc(loadTimeout),
disposeUniver: () => this._disposeUniver(),
};
@@ -121,7 +121,7 @@ export class E2EController extends Disposable {
await this._commandService.executeCommand(DisposeUniverCommand.id);
}
- private async _diposeDefaultSheetUnit(disposingTimeout: number = AWAIT_DISPOSING_TIMEOUT): Promise<void> {
+ private async _disposeDefaultSheetUnit(disposingTimeout: number = AWAIT_DISPOSING_TIMEOUT): Promise<void> {
const unit = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
const unitId = unit?.getUnitId();
await this._univerInstanceService.disposeUnit(unitId || '');
diff --git a/packages/engine-formula/src/basics/common.ts b/packages/engine-formula/src/basics/common.ts
index 63d21d83f6..61c8b7a828 100644
--- a/packages/engine-formula/src/basics/common.ts
+++ b/packages/engine-formula/src/basics/common.ts
@@ -175,6 +175,10 @@ export interface IUnitExcludedCell {
[unitId: string]: Nullable<{ [sheetId: string]: ObjectMatrix<boolean> }>;
}
+export interface IUnitRowData {
+ [unitId: string]: Nullable<{ [sheetId: string]: IObjectArrayPrimitiveType<Partial<IRowData>> }>;
+}
+
export interface IFormulaDatasetConfig {
formulaData: IFormulaData;
arrayFormulaCellData: IArrayFormulaUnitCellType;
@@ -191,6 +195,7 @@ export interface IFormulaDatasetConfig {
unitStylesData?: IUnitStylesData;
unitSheetNameMap?: IUnitSheetNameMap;
maxIteration?: number;
+ rowData?: IUnitRowData; // Include rows hidden by filters
}
export enum ConcatenateType {
diff --git a/packages/engine-formula/src/controller/calculate.controller.ts b/packages/engine-formula/src/controller/calculate.controller.ts
index 6920396b85..8d4eb04f53 100644
--- a/packages/engine-formula/src/controller/calculate.controller.ts
+++ b/packages/engine-formula/src/controller/calculate.controller.ts
@@ -78,7 +78,7 @@ export class CalculateController extends Disposable {
private async _calculate(
formulaDirtyData: Partial<IFormulaDirtyData>
) {
- const { forceCalculation: forceCalculate = false, dirtyRanges = [], dirtyNameMap = {}, dirtyDefinedNameMap = {}, dirtyUnitFeatureMap = {}, dirtyUnitOtherFormulaMap = {}, clearDependencyTreeCache = {}, maxIteration = DEFAULT_CYCLE_REFERENCE_COUNT } = formulaDirtyData;
+ const { forceCalculation: forceCalculate = false, dirtyRanges = [], dirtyNameMap = {}, dirtyDefinedNameMap = {}, dirtyUnitFeatureMap = {}, dirtyUnitOtherFormulaMap = {}, clearDependencyTreeCache = {}, maxIteration = DEFAULT_CYCLE_REFERENCE_COUNT, rowData } = formulaDirtyData;
const formulaData = this._formulaDataModel.getFormulaData();
@@ -99,6 +99,7 @@ export class CalculateController extends Disposable {
dirtyUnitOtherFormulaMap,
clearDependencyTreeCache,
maxIteration,
+ rowData,
});
}
diff --git a/packages/engine-formula/src/index.ts b/packages/engine-formula/src/index.ts
index 2b904a9177..31e7250e09 100644
--- a/packages/engine-formula/src/index.ts
+++ b/packages/engine-formula/src/index.ts
@@ -172,3 +172,4 @@ export { ENGINE_FORMULA_CYCLE_REFERENCE_COUNT, ENGINE_FORMULA_PLUGIN_CONFIG_KEY,
export { generateRandomDependencyTreeId } from './engine/dependency/formula-dependency';
export { DependencyManagerBaseService } from './services/dependency-manager.service';
export { LambdaValueObjectObject } from './engine/value-object/lambda-value-object';
+export { type IUnitRowData } from './basics/common';
diff --git a/packages/engine-formula/src/models/formula-data.model.ts b/packages/engine-formula/src/models/formula-data.model.ts
index b0c27aabf7..5cd070451f 100644
--- a/packages/engine-formula/src/models/formula-data.model.ts
+++ b/packages/engine-formula/src/models/formula-data.model.ts
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-import type { ICellData, IObjectMatrixPrimitiveType, IRange, IUnitRange, Nullable, Workbook } from '@univerjs/core';
+import type { ICellData, IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, IRange, IRowData, IUnitRange, Nullable, Workbook } from '@univerjs/core';
import type {
IArrayFormulaRangeType,
IArrayFormulaUnitCellType,
@@ -24,10 +24,12 @@ import type {
IRuntimeUnitDataType,
ISheetData,
IUnitData,
+ IUnitRowData,
IUnitSheetNameMap,
+ IUnitStylesData,
} from '../basics/common';
-import { Disposable, Inject, isFormulaId, isFormulaString, IUniverInstanceService, ObjectMatrix, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';
+import { BooleanNumber, Disposable, Inject, isFormulaId, isFormulaString, IUniverInstanceService, ObjectMatrix, RANGE_TYPE, UniverInstanceType } from '@univerjs/core';
import { LexerTreeBuilder } from '../engine/analysis/lexer-tree-builder';
import { clearArrayFormulaCellDataByCell, updateFormulaDataByCellValue } from './utils/formula-data-util';
@@ -258,6 +260,8 @@ export class FormulaDataModel extends Disposable {
const allUnitData: IUnitData = {};
+ const unitStylesData: IUnitStylesData = {};
+
const unitSheetNameMap: IUnitSheetNameMap = {};
for (const workbook of unitAllSheet) {
@@ -287,15 +291,55 @@ export class FormulaDataModel extends Disposable {
allUnitData[unitId] = sheetData;
+ unitStylesData[unitId] = workbook.getStyles();
+
unitSheetNameMap[unitId] = sheetNameMap;
}
return {
allUnitData,
+ unitStylesData,
unitSheetNameMap,
};
}
+ /**
+ * Get the hidden rows that are filtered or manually hidden.
+ *
+ * For formulas that are sensitive to hidden rows.
+ */
+ getHiddenRowsFiltered() {
+ const unitAllSheet = this._univerInstanceService.getAllUnitsForType<Workbook>(UniverInstanceType.UNIVER_SHEET);
+ const rowData: IUnitRowData = {};
+
+ for (const workbook of unitAllSheet) {
+ const unitId = workbook.getUnitId();
+ const sheets = workbook.getSheets();
+ rowData[unitId] = {};
+
+ for (const sheet of sheets) {
+ const sheetId = sheet.getSheetId();
+ rowData[unitId][sheetId] = {};
+
+ const startRow = 0;
+ const endRow = sheet.getRowCount() - 1;
+ const sheetRowData: IObjectArrayPrimitiveType<Partial<IRowData>> = {};
+
+ for (let i = startRow; i <= endRow; i++) {
+ if (!sheet.getRowVisible(i)) {
+ sheetRowData[i] = {
+ hd: BooleanNumber.TRUE,
+ };
+ }
+ }
+
+ rowData[unitId][sheetId] = sheetRowData;
+ }
+ }
+
+ return rowData;
+ }
+
updateFormulaData(unitId: string, sheetId: string, cellValue: IObjectMatrixPrimitiveType<Nullable<ICellData>>) {
const cellMatrix = new ObjectMatrix(cellValue);
diff --git a/packages/engine-formula/src/services/current-data.service.ts b/packages/engine-formula/src/services/current-data.service.ts
index 25e4443449..b303fbd01d 100644
--- a/packages/engine-formula/src/services/current-data.service.ts
+++ b/packages/engine-formula/src/services/current-data.service.ts
@@ -24,9 +24,9 @@ import type {
IFormulaData,
IFormulaDatasetConfig,
IRuntimeUnitDataType,
- ISheetData,
IUnitData,
IUnitExcludedCell,
+ IUnitRowData,
IUnitSheetIdToNameMap,
IUnitSheetNameMap,
IUnitStylesData,
@@ -34,6 +34,7 @@ import type {
import { createIdentifier, Disposable, Inject, IUniverInstanceService, LocaleService, ObjectMatrix, UniverInstanceType } from '@univerjs/core';
import { convertUnitDataToRuntime } from '../basics/runtime';
+import { FormulaDataModel } from '../models/formula-data.model';
export interface IFormulaDirtyData {
forceCalculation: boolean;
@@ -44,6 +45,7 @@ export interface IFormulaDirtyData {
dirtyUnitOtherFormulaMap: IDirtyUnitOtherFormulaMap;
clearDependencyTreeCache: IDirtyUnitSheetNameMap; // unitId -> sheetId
maxIteration?: number;
+ rowData?: IUnitRowData; // Include rows hidden by filters
}
export interface IFormulaCurrentConfigService {
@@ -144,7 +146,8 @@ export class FormulaCurrentConfigService extends Disposable implements IFormulaC
constructor(
@IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService,
- @Inject(LocaleService) private readonly _localeService: LocaleService
+ @Inject(LocaleService) private readonly _localeService: LocaleService,
+ @Inject(FormulaDataModel) private readonly _formulaDataModel: FormulaDataModel
) {
super();
}
@@ -290,6 +293,11 @@ export class FormulaCurrentConfigService extends Disposable implements IFormulaC
this._sheetNameMap = unitSheetNameMap;
}
+ // apply row data, including rows hidden by filters
+ if (config.rowData) {
+ this._applyUnitRowData(config.rowData);
+ }
+
this._formulaData = config.formulaData;
this._arrayFormulaCellData = convertUnitDataToRuntime(config.arrayFormulaCellData);
@@ -452,57 +460,47 @@ export class FormulaCurrentConfigService extends Disposable implements IFormulaC
}
private _loadSheetData() {
- const unitAllSheet = this._univerInstanceService.getAllUnitsForType<Workbook>(UniverInstanceType.UNIVER_SHEET);
-
const workbook = this._univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;
const worksheet = workbook?.getActiveSheet();
this._executeUnitId = workbook?.getUnitId();
this._executeSubUnitId = worksheet?.getSheetId();
- const allUnitData: IUnitData = {};
-
- const unitStylesData: IUnitStylesData = {};
-
- const unitSheetNameMap: IUnitSheetNameMap = {};
-
- for (const workbook of unitAllSheet) {
- const unitId = workbook.getUnitId();
+ return this._formulaDataModel.getCalculateData();
+ }
- const sheets = workbook.getSheets();
+ /**
+ * There is no filter information in the worker, it must be passed in from the main thread after it is ready
+ * @param rowData
+ */
+ private _applyUnitRowData(rowData: IUnitRowData) {
+ for (const unitId in rowData) {
+ if (rowData[unitId] == null) {
+ continue;
+ }
- const sheetData: ISheetData = {};
+ for (const sheetId in rowData[unitId]) {
+ if (rowData[unitId][sheetId] == null) {
+ continue;
+ }
- const sheetNameMap: { [sheetName: string]: string } = {};
+ if (this._unitData[unitId] == null) {
+ this._unitData[unitId] = {};
+ }
- for (const sheet of sheets) {
- const sheetId = sheet.getSheetId();
+ if (this._unitData[unitId][sheetId] == null) {
+ this._unitData[unitId][sheetId] = {
+ cellData: new ObjectMatrix({}),
+ rowCount: 0,
+ columnCount: 0,
+ rowData: {},
+ columnData: {},
+ };
+ }
- const sheetConfig = sheet.getConfig();
- sheetData[sheetId] = {
- cellData: new ObjectMatrix(sheetConfig.cellData),
- rowCount: sheetConfig.rowCount,
- columnCount: sheetConfig.columnCount,
- rowData: sheetConfig.rowData,
- columnData: sheetConfig.columnData,
- defaultRowHeight: sheetConfig.defaultRowHeight,
- defaultColumnWidth: sheetConfig.defaultColumnWidth,
- };
- sheetNameMap[sheet.getName()] = sheet.getSheetId();
+ this._unitData[unitId][sheetId].rowData = rowData[unitId][sheetId];
}
-
- allUnitData[unitId] = sheetData;
-
- unitStylesData[unitId] = workbook.getStyles();
-
- unitSheetNameMap[unitId] = sheetNameMap;
}
-
- return {
- allUnitData,
- unitStylesData,
- unitSheetNameMap,
- };
}
}
diff --git a/packages/sheets-filter-ui/package.json b/packages/sheets-filter-ui/package.json
index 4e2ac6221e..3853cbcf86 100644
--- a/packages/sheets-filter-ui/package.json
+++ b/packages/sheets-filter-ui/package.json
@@ -68,6 +68,7 @@
"dependencies": {
"@univerjs/core": "workspace:*",
"@univerjs/design": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
"@univerjs/engine-render": "workspace:*",
"@univerjs/icons": "^0.2.20",
"@univerjs/rpc": "workspace:*",
diff --git a/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts b/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts
index ad9528b696..2d8e05e6ca 100644
--- a/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts
+++ b/packages/sheets-filter-ui/src/commands/commands/__tests__/sheets-filter.command.spec.ts
@@ -19,11 +19,12 @@ import type { ISetRangeValuesCommandParams } from '@univerjs/sheets';
import type { FilterModel, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import type { ISetSheetsFilterCriteriaCommandParams } from '@univerjs/sheets-filter/commands/commands/sheets-filter.command.js';
import { AuthzIoLocalService, IAuthzIoService, ICommandService, Inject, Injector, IUniverInstanceService, LocaleType, Plugin, RANGE_TYPE, RedoCommand, UndoCommand, Univer, UniverInstanceType } from '@univerjs/core';
+import { ActiveDirtyManagerService, IActiveDirtyManagerService } from '@univerjs/engine-formula';
import { RangeProtectionRuleModel, RefRangeService, SetRangeValuesCommand, SetRangeValuesMutation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import { SetSheetsFilterRangeMutation, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
+
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, RemoveSheetFilterCommand, SetSheetFilterRangeCommand, SetSheetsFilterCriteriaCommand, SmartToggleSheetsFilterCommand } from '@univerjs/sheets-filter/commands/commands/sheets-filter.command.js';
import { IMessageService } from '@univerjs/ui';
-
import { MockMessageService } from '@univerjs/ui/services/message/__testing__/mock-message.service.js';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
@@ -100,6 +101,7 @@ function createFilterCommandTestBed() {
[WorksheetProtectionRuleModel],
[RangeProtectionRuleModel],
[IMessageService, { useClass: MockMessageService }],
+ [IActiveDirtyManagerService, { useClass: ActiveDirtyManagerService }],
] as Dependency[]).forEach((d) => this._injector.add(d));
this._injector.get(SheetInterceptorService);
@@ -149,7 +151,6 @@ describe('test sheets filter commands', () => {
});
afterEach(() => {
- univer.dispose();
});
function select(range: IRange) {
diff --git a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
index fedd07a9a5..a580b93dcf 100644
--- a/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
+++ b/packages/sheets-filter-ui/src/commands/operations/__tests__/sheets-filter.operation.spec.ts
@@ -18,6 +18,7 @@ import type { Dependency, IOperation, IWorkbookData, Workbook } from '@univerjs/
import type { ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import type { IEditorBridgeServiceVisibleParam } from '@univerjs/sheets-ui';
import { CommandType, ICommandService, IContextService, Inject, Injector, LocaleService, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';
+import { ActiveDirtyManagerService, IActiveDirtyManagerService } from '@univerjs/engine-formula';
import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
import { SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
@@ -78,6 +79,7 @@ function createFilterOperationTestBed() {
[SheetsFilterPanelService],
[RefRangeService],
[SheetsSelectionsService],
+ [IActiveDirtyManagerService, { useClass: ActiveDirtyManagerService }],
] as Dependency[]).forEach((d) => this._injector.add(d));
}
}
diff --git a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
index 558ee3791b..46b5af6419 100644
--- a/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
+++ b/packages/sheets-filter-ui/src/controllers/__tests__/sheets-filter.menu.spec.ts
@@ -17,6 +17,7 @@
import type { IWorkbookData, Workbook } from '@univerjs/core';
import type { ISetSheetsFilterCriteriaMutationParams, ISetSheetsFilterRangeMutationParams } from '@univerjs/sheets-filter';
import { AuthzIoLocalService, DisposableCollection, IAuthzIoService, ICommandService, Inject, Injector, LocaleType, Plugin, Univer, UniverInstanceType } from '@univerjs/core';
+import { ActiveDirtyManagerService, IActiveDirtyManagerService } from '@univerjs/engine-formula';
import { ExclusiveRangeService, IExclusiveRangeService, RangeProtectionRuleModel, RefRangeService, SetWorksheetActiveOperation, SheetInterceptorService, SheetsSelectionsService, WorkbookPermissionService, WorksheetPermissionService, WorksheetProtectionPointModel, WorksheetProtectionRuleModel } from '@univerjs/sheets';
import { RemoveSheetsFilterMutation, SetSheetsFilterCriteriaMutation, SetSheetsFilterRangeMutation, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, SmartToggleSheetsFilterCommand } from '@univerjs/sheets-filter/commands/commands/sheets-filter.command.js';
@@ -77,6 +78,7 @@ function createSheetsFilterMenuTestBed() {
injector.add([SheetInterceptorService]);
injector.add([RangeProtectionRuleModel]);
injector.add([IExclusiveRangeService, { useClass: ExclusiveRangeService, deps: [SheetsSelectionsService] }]);
+ injector.add([IActiveDirtyManagerService, { useClass: ActiveDirtyManagerService }]);
const commandService = injector.get(ICommandService);
[
diff --git a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
index 4e5de8c78e..c77b4634d4 100644
--- a/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
+++ b/packages/sheets-filter-ui/src/services/__tests__/sheets-filter-panel.service.spec.ts
@@ -20,6 +20,7 @@ import type { IOpenFilterPanelOperationParams } from '../../commands/operations/
import type { IFilterConditionFormParams } from '../../models/conditions';
import type { IFilterByValueWithTreeItem } from '../sheets-filter-panel.service';
import { CommandType, ICommandService, Inject, Injector, LocaleService, Plugin, Univer, UniverInstanceType } from '@univerjs/core';
+import { ActiveDirtyManagerService, IActiveDirtyManagerService } from '@univerjs/engine-formula';
import { RefRangeService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
import { CustomFilterOperator, SheetsFilterService, UniverSheetsFilterPlugin } from '@univerjs/sheets-filter';
import { SetSheetsFilterCriteriaCommand } from '@univerjs/sheets-filter/commands/commands/sheets-filter.command.js';
@@ -94,6 +95,7 @@ function createSheetsFilterPanelServiceTestBed(workbookData: IWorkbookData) {
[SheetsSelectionsService],
[SheetInterceptorService],
[SheetsFilterPanelService],
+ [IActiveDirtyManagerService, { useClass: ActiveDirtyManagerService }],
] as Dependency[]).forEach((d) => this._injector.add(d));
}
}
diff --git a/packages/sheets-filter/package.json b/packages/sheets-filter/package.json
index ada2942e69..31cdd23823 100644
--- a/packages/sheets-filter/package.json
+++ b/packages/sheets-filter/package.json
@@ -66,6 +66,8 @@
},
"dependencies": {
"@univerjs/core": "workspace:*",
+ "@univerjs/engine-formula": "workspace:*",
+ "@univerjs/rpc": "workspace:*",
"@univerjs/sheets": "workspace:*"
},
"devDependencies": {
diff --git a/packages/sheets-filter/src/plugin.ts b/packages/sheets-filter/src/plugin.ts
index ce36463ab6..10cd85921b 100644
--- a/packages/sheets-filter/src/plugin.ts
+++ b/packages/sheets-filter/src/plugin.ts
@@ -17,9 +17,10 @@
import type { Dependency } from '@univerjs/core';
import type { IUniverSheetsFilterConfig } from './controllers/config.schema';
-import { IConfigService, Inject, Injector, merge, Plugin, UniverInstanceType } from '@univerjs/core';
+import { IConfigService, Inject, Injector, merge, Plugin, touchDependencies, UniverInstanceType } from '@univerjs/core';
import { defaultPluginConfig, SHEETS_FILTER_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
import { SheetsFilterController } from './controllers/sheets-filter.controller';
+import { SheetsFilterFormulaService } from './services/sheet-filter-formula.service';
import { SHEET_FILTER_SNAPSHOT_ID, SheetsFilterService } from './services/sheet-filter.service';
export class UniverSheetsFilterPlugin extends Plugin {
@@ -44,12 +45,16 @@ export class UniverSheetsFilterPlugin extends Plugin {
override onStarting(): void {
([
+ [SheetsFilterFormulaService],
[SheetsFilterService],
[SheetsFilterController],
] as Dependency[]).forEach((d) => this._injector.add(d));
}
override onReady(): void {
- this._injector.get(SheetsFilterController);
+ touchDependencies(this._injector, [
+ [SheetsFilterFormulaService],
+ [SheetsFilterController],
+ ]);
}
}
diff --git a/packages/sheets-filter/src/services/sheet-filter-formula.service.ts b/packages/sheets-filter/src/services/sheet-filter-formula.service.ts
new file mode 100644
index 0000000000..118bd03183
--- /dev/null
+++ b/packages/sheets-filter/src/services/sheet-filter-formula.service.ts
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { Workbook } from '@univerjs/core';
+import type { ISheetCommandSharedParams } from '@univerjs/sheets';
+import { Disposable, Inject, IUniverInstanceService } from '@univerjs/core';
+import { IActiveDirtyManagerService } from '@univerjs/engine-formula';
+import { FILTER_MUTATIONS } from '../common/const';
+import { SheetsFilterService } from './sheet-filter.service';
+
+/**
+ * Hidden rows after filtering affect formula calculations, such as SUBTOTAL
+ */
+export class SheetsFilterFormulaService extends Disposable {
+ constructor(
+ @Inject(IActiveDirtyManagerService) private _activeDirtyManagerService: IActiveDirtyManagerService,
+ @Inject(SheetsFilterService) private _sheetsFilterService: SheetsFilterService,
+ @IUniverInstanceService private readonly _univerInstanceService: IUniverInstanceService
+ ) {
+ super();
+
+ this._initFormulaDirtyRange();
+ }
+
+ private _initFormulaDirtyRange() {
+ FILTER_MUTATIONS.forEach((commandId) => {
+ this._activeDirtyManagerService.register(
+ commandId,
+ {
+ commandId,
+ getDirtyData: (commandInfo) => {
+ const params = commandInfo.params as ISheetCommandSharedParams;
+ const { unitId, subUnitId } = params;
+ return {
+ dirtyRanges: this._getHideRowMutation(unitId, subUnitId),
+ clearDependencyTreeCache: {
+ [unitId]: {
+ [subUnitId]: '1',
+ },
+ },
+ };
+ },
+ }
+ );
+ });
+ }
+
+ private _getHideRowMutation(unitId: string, subUnitId: string) {
+ const range = this._sheetsFilterService.getFilterModel(unitId, subUnitId)?.getRange();
+
+ const sheet = this._univerInstanceService.getUnit<Workbook>(unitId)?.getSheetBySheetId(subUnitId);
+
+ if (range == null || sheet == null) {
+ return [];
+ }
+
+ const { startRow, endRow } = range;
+
+ // covert hidden rows to dirtyRanges
+ const dirtyRanges = [{
+ unitId,
+ sheetId: subUnitId,
+ range: {
+ startRow,
+ startColumn: 0,
+ endRow,
+ endColumn: sheet.getColumnCount() - 1,
+ },
+ }];
+
+ return dirtyRanges;
+ }
+}
diff --git a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
index d5c251dc60..48e79396eb 100644
--- a/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
+++ b/packages/sheets-formula-ui/src/controllers/__tests__/update-formula.controller.spec.ts
@@ -17,9 +17,10 @@
import type { ICellData, Injector, IWorkbookData, Nullable, Univer, Workbook } from '@univerjs/core';
import type { ISetDefinedNameMutationParam } from '@univerjs/engine-formula';
import type { IDeleteRangeMoveLeftCommandParams, IDeleteRangeMoveUpCommandParams, IInsertColCommandParams, IInsertRowCommandParams, IMoveColsCommandParams, IMoveRangeCommandParams, IMoveRowsCommandParams, InsertRangeMoveDownCommandParams, InsertRangeMoveRightCommandParams, IRemoveRowColCommandParams, IRemoveSheetCommandParams, ISetRangeValuesCommandParams, ISetWorksheetNameCommandParams } from '@univerjs/sheets';
+import type { ISetRowHiddenCommandParams } from '@univerjs/sheets/commands/commands/set-row-visible.command.js';
import { CellValueType, Direction, ICommandService, IUniverInstanceService, LocaleType, RANGE_TYPE, RedoCommand, UndoCommand } from '@univerjs/core';
import { RemoveDefinedNameMutation, SetArrayFormulaDataMutation, SetDefinedNameMutation, SetFormulaDataMutation } from '@univerjs/engine-formula';
-import { DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertColByRangeCommand, InsertColCommand, InsertColMutation, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertRowCommand, InsertRowMutation, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, RemoveColByRangeCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, SetDefinedNameCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetSelectionsOperation, SetWorksheetNameCommand, SetWorksheetNameMutation, SheetsSelectionsService } from '@univerjs/sheets';
+import { DeleteRangeMoveLeftCommand, DeleteRangeMoveUpCommand, InsertColByRangeCommand, InsertColCommand, InsertColMutation, InsertRangeMoveDownCommand, InsertRangeMoveRightCommand, InsertRowByRangeCommand, InsertRowCommand, InsertRowMutation, MoveColsCommand, MoveColsMutation, MoveRangeCommand, MoveRangeMutation, MoveRowsCommand, MoveRowsMutation, RemoveColByRangeCommand, RemoveColCommand, RemoveColMutation, RemoveDefinedNameCommand, RemoveRowByRangeCommand, RemoveRowCommand, RemoveRowMutation, RemoveSheetCommand, RemoveSheetMutation, SetColHiddenCommand, SetColHiddenMutation, SetColVisibleMutation, SetDefinedNameCommand, SetRangeValuesCommand, SetRangeValuesMutation, SetRowHiddenCommand, SetRowHiddenMutation, SetRowVisibleMutation, SetSelectionsOperation, SetSpecificColsVisibleCommand, SetSpecificRowsVisibleCommand, SetWorksheetNameCommand, SetWorksheetNameMutation, SheetsSelectionsService } from '@univerjs/sheets';
import { UpdateFormulaController } from '@univerjs/sheets-formula';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { createCommandTestBed } from './create-command-test-bed';
@@ -276,10 +277,82 @@ const TEST_WORKBOOK_DATA_DEMO = (): IWorkbookData => ({
},
name: 'Sheet2',
},
+ sheet3: {
+ id: 'sheet3',
+ cellData: {
+ 0: {
+ 0: {
+ v: 1,
+ t: 2,
+ },
+ 3: {
+ f: '=A1:A5',
+ v: 1,
+ t: 2,
+ },
+ },
+ 1: {
+ 0: {
+ v: 2,
+ t: 2,
+ },
+ },
+ 2: {
+ 0: {
+ v: 3,
+ t: 2,
+ },
+ },
+ 3: {
+ 0: {
+ v: 4,
+ t: 2,
+ },
+ },
+ 4: {
+ 0: {
+ v: 5,
+ t: 2,
+ },
+ },
+ 5: {
+ 0: {
+ f: '=SUBTOTAL(109,A1:A5)',
+ v: 15,
+ t: 2,
+ },
+ 1: {
+ f: '=SUBTOTAL(109,A3)',
+ v: 3,
+ t: 2,
+ },
+ 2: {
+ f: '=A3',
+ v: 3,
+ t: 2,
+ },
+ },
+ },
+ name: 'Sheet3',
+ },
+ sheet4: {
+ id: 'sheet4',
+ cellData: {
+ 0: {
+ 0: {
+ f: '=SUBTOTAL(109,Sheet3!A1:A5)',
+ v: 15,
+ t: 2,
+ },
+ },
+ },
+ name: 'Sheet4',
+ },
+
},
locale: LocaleType.ZH_CN,
name: '',
- sheetOrder: ['sheet1', 'sheet2'],
+ sheetOrder: ['sheet1', 'sheet2', 'sheet3', 'sheet4'],
styles: {},
resources: [
{
@@ -361,6 +434,15 @@ describe('Test update formula ', () => {
].forEach((command) => {
commandService.registerCommand(command);
});
+ // hide row/column
+ commandService.registerCommand(SetRowHiddenCommand);
+ commandService.registerCommand(SetRowHiddenMutation);
+ commandService.registerCommand(SetSpecificRowsVisibleCommand);
+ commandService.registerCommand(SetRowVisibleMutation);
+ commandService.registerCommand(SetColHiddenCommand);
+ commandService.registerCommand(SetColHiddenMutation);
+ commandService.registerCommand(SetSpecificColsVisibleCommand);
+ commandService.registerCommand(SetColVisibleMutation);
getValues = (
startRow: number,
@@ -1627,5 +1709,27 @@ describe('Test update formula ', () => {
const values = getValues(7, 8, 7, 9);
expect(values).toStrictEqual([[{ }, { f: '=SUM(C8:E10)', si: 'CarNau' }]]);
});
+
+ it('hide row and show row', async () => {
+ const params: ISetRowHiddenCommandParams = {
+ unitId: 'test',
+ subUnitId: 'sheet3',
+ ranges: [{
+ startRow: 2,
+ startColumn: 0,
+ endRow: 2,
+ endColumn: 19,
+ rangeType: RANGE_TYPE.ROW,
+ }],
+ };
+
+ expect(await commandService.executeCommand(SetRowHiddenCommand.id, params)).toBeTruthy();
+ const values = getValues(5, 0, 5, 2, 'sheet3');
+
+ // No change in the formula
+ expect(values?.[0][0]?.f).toStrictEqual('=SUBTOTAL(109,A1:A5)');
+ expect(values?.[0][1]?.f).toStrictEqual('=SUBTOTAL(109,A3)');
+ expect(values?.[0][2]?.f).toStrictEqual('=A3');
+ });
});
});
diff --git a/packages/sheets-formula/src/controllers/active-dirty.controller.ts b/packages/sheets-formula/src/controllers/active-dirty.controller.ts
index b4b9508dfc..cf943e4a4c 100644
--- a/packages/sheets-formula/src/controllers/active-dirty.controller.ts
+++ b/packages/sheets-formula/src/controllers/active-dirty.controller.ts
@@ -28,6 +28,8 @@ import type {
IRemoveSheetMutationParams,
IReorderRangeMutationParams,
ISetRangeValuesMutationParams,
+ ISetRowHiddenMutationParams,
+ ISetRowVisibleMutationParams,
} from '@univerjs/sheets';
import {
Disposable,
@@ -48,6 +50,8 @@ import {
RemoveSheetMutation,
ReorderRangeMutation,
SetRangeValuesMutation,
+ SetRowHiddenMutation,
+ SetRowVisibleMutation,
SetStyleCommand,
} from '@univerjs/sheets';
@@ -89,6 +93,8 @@ export class ActiveDirtyController extends Disposable {
this._initialRowAndColumn();
+ this._initialHideRow();
+
this._initialSheet();
this._initialDefinedName();
@@ -217,6 +223,37 @@ export class ActiveDirtyController extends Disposable {
});
}
+ private _initialHideRow() {
+ this._activeDirtyManagerService.register(SetRowHiddenMutation.id, {
+ commandId: SetRowHiddenMutation.id,
+ getDirtyData: (command: ICommandInfo) => {
+ const params = command.params as ISetRowHiddenMutationParams;
+ return {
+ dirtyRanges: this._getHideRowMutation(params),
+ clearDependencyTreeCache: {
+ [params.unitId]: {
+ [params.subUnitId]: '1',
+ },
+ },
+ };
+ },
+ });
+ this._activeDirtyManagerService.register(SetRowVisibleMutation.id, {
+ commandId: SetRowVisibleMutation.id,
+ getDirtyData: (command: ICommandInfo) => {
+ const params = command.params as ISetRowVisibleMutationParams;
+ return {
+ dirtyRanges: this._getHideRowMutation(params),
+ clearDependencyTreeCache: {
+ [params.unitId]: {
+ [params.subUnitId]: '1',
+ },
+ },
+ };
+ },
+ });
+ }
+
private _initialSheet() {
this._activeDirtyManagerService.register(RemoveSheetMutation.id, {
commandId: RemoveSheetMutation.id,
@@ -374,6 +411,20 @@ export class ActiveDirtyController extends Disposable {
return dirtyRanges;
}
+ private _getHideRowMutation(params: ISetRowHiddenMutationParams) {
+ const { subUnitId, unitId, ranges } = params;
+
+ const dirtyRanges: IUnitRange[] = [];
+
+ // covert ranges to dirtyRanges
+ ranges.forEach((range) => {
+ const matrix = this._rangeToMatrix(range).getMatrix();
+ dirtyRanges.push(...this._getDirtyRangesByCellValue(unitId, subUnitId, matrix));
+ });
+
+ return dirtyRanges;
+ }
+
private _getRemoveSheetMutation(params: IRemoveSheetMutationParams) {
const dirtyNameMap: IDirtyUnitSheetNameMap = {};
const { subUnitId: sheetId, unitId, subUnitName } = params;
diff --git a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
index 9f5235db6d..f4b7b56e44 100644
--- a/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
+++ b/packages/sheets-formula/src/controllers/trigger-calculation.controller.ts
@@ -167,6 +167,17 @@ export class TriggerCalculationController extends Disposable {
}
private _commandExecutedListener() {
+ // The filtering information is not synchronized to the worker and must be passed in from the main thread each time
+ this.disposeWithMe(
+ this._commandService.beforeCommandExecuted((command: ICommandInfo) => {
+ if (command.id === SetFormulaCalculationStartMutation.id) {
+ const params = command.params as ISetFormulaCalculationStartMutation;
+
+ params.rowData = this._formulaDataModel.getHiddenRowsFiltered();
+ }
+ })
+ );
+
this.disposeWithMe(
this._commandService.onCommandExecuted((command: ICommandInfo, options) => {
if (!this._activeDirtyManagerService.get(command.id)) {
diff --git a/packages/sheets-formula/src/controllers/update-formula.controller.ts b/packages/sheets-formula/src/controllers/update-formula.controller.ts
index dfe782f2e1..ca0660ae62 100644
--- a/packages/sheets-formula/src/controllers/update-formula.controller.ts
+++ b/packages/sheets-formula/src/controllers/update-formula.controller.ts
@@ -262,12 +262,12 @@ export class UpdateFormulaController extends Disposable {
const config = this._configService.getConfig<IUniverSheetsFormulaBaseConfig>(PLUGIN_CONFIG_KEY_BASE);
const calculationMode = config?.initialFormulaComputing ?? CalculationMode.WHEN_EMPTY;
- const params = this._getDiryDataByCalculationMode(calculationMode);
+ const params = this._getDirtyDataByCalculationMode(calculationMode);
this._commandService.executeCommand(SetFormulaCalculationStartMutation.id, params, { onlyLocal: true });
}
- private _getDiryDataByCalculationMode(calculationMode: CalculationMode): IFormulaDirtyData {
+ private _getDirtyDataByCalculationMode(calculationMode: CalculationMode): IFormulaDirtyData {
const forceCalculation = calculationMode === CalculationMode.FORCED;
// loop all sheets cell data, and get the dirty data
diff --git a/packages/sheets/src/controllers/basic-worksheet.controller.ts b/packages/sheets/src/controllers/basic-worksheet.controller.ts
index 5164b61f4b..1d9ed6f269 100644
--- a/packages/sheets/src/controllers/basic-worksheet.controller.ts
+++ b/packages/sheets/src/controllers/basic-worksheet.controller.ts
@@ -200,8 +200,6 @@ export class BasicWorksheetController extends Disposable implements IDisposable
EmptyMutation,
SetRowHiddenMutation, // formula SUBTOTAL
SetRowVisibleMutation,
- SetColHiddenMutation,
- SetColVisibleMutation,
] as IMutation<object>[]).forEach((mutation) => {
this._commandService.registerCommand(mutation);
this._dataSyncPrimaryController?.registerSyncingMutations(mutation);
@@ -254,6 +252,8 @@ export class BasicWorksheetController extends Disposable implements IDisposable
SetBorderPositionCommand,
SetBorderStyleCommand,
SetColHiddenCommand,
+ SetColHiddenMutation,
+ SetColVisibleMutation,
SetColWidthCommand,
SetColDataCommand,
SetColDataMutation,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b434c4cb76..81d21226ea 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -2303,6 +2303,12 @@ importers:
'@univerjs/core':
specifier: workspace:*
version: link:../core
+ '@univerjs/engine-formula':
+ specifier: workspace:*
+ version: link:../engine-formula
+ '@univerjs/rpc':
+ specifier: workspace:*
+ version: link:../rpc
'@univerjs/sheets':
specifier: workspace:*
version: link:../sheets
@@ -2331,6 +2337,9 @@ importers:
'@univerjs/design':
specifier: workspace:*
version: link:../design
+ '@univerjs/engine-formula':
+ specifier: workspace:*
+ version: link:../engine-formula
'@univerjs/engine-render':
specifier: workspace:*
version: link:../engine-render