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(sheets): set value error on formula cell (#4527)

zhangwa6a18e58df19
diff --git a/packages/sheets/src/facade/__tests__/utils.spec.ts b/packages/sheets/src/facade/__tests__/utils.spec.ts
index 4b723b0b43..8dd668286a 100644
--- a/packages/sheets/src/facade/__tests__/utils.spec.ts
+++ b/packages/sheets/src/facade/__tests__/utils.spec.ts
@@ -19,11 +19,11 @@ import { covertCellValue, covertCellValues } from '../utils';
describe('Test utils', () => {
it('function covertCellValue', () => {
- expect(covertCellValue('=SUM(1)')).toStrictEqual({ f: '=SUM(1)' });
+ expect(covertCellValue('=SUM(1)')).toStrictEqual({ f: '=SUM(1)', v: null, p: null });
- expect(covertCellValue('1')).toStrictEqual({ v: '1' });
- expect(covertCellValue(1)).toStrictEqual({ v: 1 });
- expect(covertCellValue(true)).toStrictEqual({ v: true });
+ expect(covertCellValue('1')).toStrictEqual({ v: '1', f: null, p: null });
+ expect(covertCellValue(1)).toStrictEqual({ v: 1, f: null, p: null });
+ expect(covertCellValue(true)).toStrictEqual({ v: true, f: null, p: null });
expect(covertCellValue({})).toStrictEqual({});
});
@@ -38,8 +38,8 @@ describe('Test utils', () => {
{ startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
)
).toStrictEqual({
- 1: { 1: { v: 1 }, 2: { v: 2 } },
- 2: { 1: { v: 3 }, 2: { v: 4 } },
+ 1: { 1: { v: 1, f: null, p: null }, 2: { v: 2, f: null, p: null } },
+ 2: { 1: { v: 3, f: null, p: null }, 2: { v: 4, f: null, p: null } },
});
expect(
@@ -51,8 +51,8 @@ describe('Test utils', () => {
{ startRow: 1, startColumn: 1, endRow: 2, endColumn: 2 }
)
).toStrictEqual({
- 1: { 1: { v: 1 }, 2: { v: 2 } },
- 2: { 1: { v: 3 }, 2: { v: 4 } },
+ 1: { 1: { v: 1, f: null, p: null }, 2: { v: 2, f: null, p: null } },
+ 2: { 1: { v: 3, f: null, p: null }, 2: { v: 4, f: null, p: null } },
});
expect(
diff --git a/packages/sheets/src/facade/utils.ts b/packages/sheets/src/facade/utils.ts
index 57a3438a5a..90018b6c61 100644
--- a/packages/sheets/src/facade/utils.ts
+++ b/packages/sheets/src/facade/utils.ts
@@ -106,11 +106,15 @@ export function covertCellValue(value: CellValue | ICellData): ICellData {
if (isFormulaString(value)) {
return {
f: value as string,
+ v: null,
+ p: null,
};
}
if (isCellV(value)) {
return {
v: value as Nullable<CellValue>,
+ p: null,
+ f: null,
};
}
if (isICellData(value)) {