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: fix the issue of border styles being lost after cell merging (#6557)

wpxp123456797f587a910c
diff --git a/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts b/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
index f3900bc01f..24e502e179 100644
--- a/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
+++ b/packages/sheets-ui/src/commands/commands/__tests__/add-worksheet-merge.command.spec.ts
@@ -485,7 +485,11 @@ describe('Test add worksheet merge commands', () => {
pattern: '0%',
},
});
- expect(worksheet.getCellRaw(20, 1)).toBeUndefined();
+ expect(worksheet.getCellStyle(20, 1)).toStrictEqual({
+ n: {
+ pattern: '0%',
+ },
+ });
});
});
diff --git a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts b/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts
index 9f4e858a0c..8cb4b56714 100644
--- a/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts
+++ b/packages/sheets/src/commands/commands/add-worksheet-merge.command.ts
@@ -134,7 +134,20 @@ export function getClearContentMutationParamForRange(worksheet: Worksheet, range
if (!leftTopCellValue && worksheet.cellHasValue(cellData) && (cellData.v !== '' || (cellData.p?.body?.dataStream?.length ?? 0) > 2)) {
leftTopCellValue = cellData;
}
- redoMatrix.setValue(row, col, null);
+ redoMatrix.setValue(
+ row,
+ col,
+ cellData.s
+ ? {
+ v: null,
+ t: null,
+ f: null,
+ si: null,
+ p: null,
+ s: cellData.s,
+ }
+ : null
+ );
}
});
redoMatrix.setValue(startRow, startColumn, leftTopCellValue);