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.

chore(formula): row array foreach

Dushusir75ebf9da4b99
diff --git a/examples/univer-sheet-ts/src/main.tsx b/examples/univer-sheet-ts/src/main.tsx
index bd924d5cb6..f69c9e7941 100644
--- a/examples/univer-sheet-ts/src/main.tsx
+++ b/examples/univer-sheet-ts/src/main.tsx
@@ -7,6 +7,7 @@ import { OperationPlugin } from '@univerjs/sheets-plugin-operation';
import { ImportXlsxPlugin } from '@univerjs/sheets-plugin-import-xlsx';
import { OverGridImagePlugin } from '@univerjs/sheets-plugin-image';
import { FindPlugin } from '@univerjs/sheets-plugin-find';
+import { DEFAULT_FORMULA_DATA_DEMO, FormulaPlugin } from '@univerjs/sheets-plugin-formula';
const uiDefaultConfigDemo = {
container: 'universheet',
@@ -66,7 +67,7 @@ univer.install(
})
);
-// FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(universheet);
+FormulaPlugin.create(DEFAULT_FORMULA_DATA_DEMO).installTo(universheet);
FindPlugin.create().installTo(universheet);
universheet.installPlugin(new OperationPlugin());
universheet.installPlugin(new ImportXlsxPlugin());
diff --git a/packages/sheets-plugin-formula/src/Basics/Register/FormulaCellEditExtension.ts b/packages/sheets-plugin-formula/src/Basics/Register/FormulaCellEditExtension.ts
index b922150545..7c39071d06 100644
--- a/packages/sheets-plugin-formula/src/Basics/Register/FormulaCellEditExtension.ts
+++ b/packages/sheets-plugin-formula/src/Basics/Register/FormulaCellEditExtension.ts
@@ -1,6 +1,5 @@
-import { IFormulaData } from '@univerjs/base-formula-engine';
import { BaseCellEditExtension, BaseCellEditExtensionFactory, ICell } from '@univerjs/base-ui';
-import { IRangeData, Nullable, ObjectArray } from '@univerjs/core';
+import { IRangeData, Nullable } from '@univerjs/core';
import { SheetUIPlugin, SHEET_UI_PLUGIN_NAME } from '@univerjs/ui-plugin-sheets';
import { FormulaPlugin } from '../../FormulaPlugin';
@@ -48,9 +47,17 @@ export class FormulaCellEditExtensionFactory extends BaseCellEditExtensionFactor
const sheetId = sheetIds[i];
const cellData = sheetData[sheetId];
Object.keys(cellData).forEach((cellRow) => {
- const rowArray = cellData[Number(cellRow)] as unknown as ObjectArray<IFormulaData>;
- rowArray.forEach((cellColumn: number, value: IFormulaData) => {
- if (Number(cellRow) === row && cellColumn === column) {
+ const rowArray = cellData[Number(cellRow)];
+ // rowArray.forEach((cellColumn: number, value: IFormulaData) => {
+ // if (Number(cellRow) === row && cellColumn === column) {
+ // // Get the content of the formula and convert it into a DOM structure
+ // formula = this._plugin.getFormulaPromptController().cellInputHandler.functionHTMLGenerate(value.formula);
+ // return false;
+ // }
+ // });
+ Object.keys(rowArray).forEach((cellColumn) => {
+ const value = rowArray[Number(cellColumn)];
+ if (Number(cellRow) === row && Number(cellColumn) === column) {
// Get the content of the formula and convert it into a DOM structure
formula = this._plugin.getFormulaPromptController().cellInputHandler.functionHTMLGenerate(value.formula);
return false;