Skip to content

Commit

Permalink
fix(formula): dirty range
Browse files Browse the repository at this point in the history
  • Loading branch information
Dushusir committed Nov 6, 2024
1 parent 14f0043 commit 23bf3e3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
44 changes: 42 additions & 2 deletions examples/src/sheets/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { UniverDocsPlugin } from '@univerjs/docs';
import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
import { UniverSheetsConditionalFormattingPlugin } from '@univerjs/sheets-conditional-formatting';
Expand Down Expand Up @@ -145,7 +144,48 @@ userManagerService.setCurrentUser(mockUser);

// create univer sheet instance
if (!IS_E2E) {
univer.createUnit(UniverInstanceType.UNIVER_SHEET, DEFAULT_WORKBOOK_DATA_DEMO);
univer.createUnit(UniverInstanceType.UNIVER_SHEET, {
id: 'test',
appVersion: '3.0.0-alpha',
sheets: {
sheet1: {
id: 'sheet1',
name: 'sheet1',
cellData: {
0: {
3: {
f: '=SUM(A1)',
si: '3e4r5t',
},
},
1: {
3: {
f: '=SUM(A2)',
si: 'OSPtzm',
},
},
2: {
3: {
si: 'OSPtzm',
},
},
3: {
3: {
si: 'OSPtzm',
},
},
},
rowCount: 100,
columnCount: 100,
},
},
locale: LocaleType.ZH_CN,
name: '',
sheetOrder: [],
styles: {},
resources: [
],
});
}

setTimeout(() => {
Expand Down
6 changes: 5 additions & 1 deletion packages/engine-formula/src/models/formula-data.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,12 @@ export class FormulaDataModel extends Disposable {
const column = Number(columnStr);

const currentCell = sheetInstance.getCellRaw(row, column);

// Calculation is only required when there is only a formula and no value
if (!currentCell || !currentCell.f || ('v' in currentCell)) continue;
const isFormula = isFormulaString(currentCell?.f) || isFormulaId(currentCell?.si);
const noValue = currentCell?.v === undefined;

if (!(isFormula && noValue)) continue;

if (!columnRanges[column]) columnRanges[column] = [];

Expand Down

0 comments on commit 23bf3e3

Please sign in to comment.