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): fix styles were lost after the cell formula was cleared (#6371)

wpxp1234565926560c5c08
diff --git a/packages/sheets-formula/src/controllers/utils/__tests__/ref-range-formula.spec.ts b/packages/sheets-formula/src/controllers/utils/__tests__/ref-range-formula.spec.ts
index 3d54932524..aab27e1802 100644
--- a/packages/sheets-formula/src/controllers/utils/__tests__/ref-range-formula.spec.ts
+++ b/packages/sheets-formula/src/controllers/utils/__tests__/ref-range-formula.spec.ts
@@ -130,7 +130,10 @@ describe('Ref range formula test', () => {
f: null,
si: 'id2',
},
- 3: null,
+ 3: {
+ f: null,
+ si: null,
+ },
},
};
expect(formulaDataToCellData(formulaData)).toStrictEqual(cellData);
diff --git a/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts b/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts
index 4303b7f01c..6cf4676b28 100644
--- a/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts
+++ b/packages/sheets-formula/src/controllers/utils/ref-range-formula.ts
@@ -591,7 +591,10 @@ function getUndoFormulaData(rangeList: IRangeChange[], oldFormulaMatrix: ObjectM
export function formulaDataItemToCellData(formulaDataItem: Nullable<IFormulaDataItem>): Nullable<ICellData> {
if (formulaDataItem == null) {
// null presents clearing cell content
- return null;
+ return {
+ f: null,
+ si: null,
+ };
}
const { f, si, x = 0, y = 0 } = formulaDataItem;
const checkFormulaString = isFormulaString(f);