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 data issues after moving range (#5749)

wpxp123456a37cfeca6dd6
diff --git a/packages/sheets/src/commands/mutations/move-range.mutation.ts b/packages/sheets/src/commands/mutations/move-range.mutation.ts
index 90ab8dd173..c3aa611af9 100644
--- a/packages/sheets/src/commands/mutations/move-range.mutation.ts
+++ b/packages/sheets/src/commands/mutations/move-range.mutation.ts
@@ -58,11 +58,19 @@ export const MoveRangeMutation: IMutation<IMoveRangeMutationParams, boolean> = {
const toCellMatrix = toWorksheet.getCellMatrix();
new ObjectMatrix<Nullable<ICellData>>(from.value).forValue((row, col, newVal) => {
- fromCellMatrix.setValue(row, col, newVal);
+ if (newVal === null || newVal === undefined) {
+ fromCellMatrix.realDeleteValue(row, col);
+ } else {
+ fromCellMatrix.setValue(row, col, newVal);
+ }
});
new ObjectMatrix<Nullable<ICellData>>(to.value).forValue((row, col, newVal) => {
- toCellMatrix.setValue(row, col, newVal);
+ if (newVal === null || newVal === undefined) {
+ toCellMatrix.realDeleteValue(row, col);
+ } else {
+ toCellMatrix.setValue(row, col, newVal);
+ }
});
return true;