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 apply & bug

jerry8ae4f57d8107
diff --git a/packages/base-sheets/src/Controller/SheetBarController.ts b/packages/base-sheets/src/Controller/SheetBarController.ts
index 71031893c4..8923609a44 100644
--- a/packages/base-sheets/src/Controller/SheetBarController.ts
+++ b/packages/base-sheets/src/Controller/SheetBarController.ts
@@ -665,6 +665,13 @@ class SheetBarAPIControl {
const context = plugin.getContext();
const workbook = context.getWorkBook();
workbook.insertSheet();
+
+ const size = workbook.getSheetSize();
+ const sheets = workbook.getSheets();
+ const lastSheet = sheets[size - 1];
+ if (lastSheet) {
+ lastSheet.activate();
+ }
}
/**
diff --git a/packages/core/src/Sheets/Apply/RemoveSheet.ts b/packages/core/src/Sheets/Apply/RemoveSheet.ts
index 4a044fef7a..1bc939de05 100644
--- a/packages/core/src/Sheets/Apply/RemoveSheet.ts
+++ b/packages/core/src/Sheets/Apply/RemoveSheet.ts
@@ -1,5 +1,6 @@
import { Workbook } from '../Domain';
import { IWorksheetConfig } from '../../Interfaces';
+import { CommandUnit, IRemoveSheetActionData } from '../../Command';
export function RemoveSheet(
workbook: Workbook,
@@ -33,4 +34,32 @@ export function RemoveSheet(
};
}
-export function RemoveSheetApply() {}
+export function RemoveSheetApply(unit: CommandUnit, data: IRemoveSheetActionData) {
+ let workbook = unit.WorkBookUnit;
+ let sheetId = data.sheetId;
+
+ const iSheets = workbook!.getWorksheets();
+ const config = workbook!.getConfig();
+
+ const { sheets } = config;
+ if (sheets[sheetId] == null) {
+ throw new Error(`Remove Sheet fail ${sheetId} is not exist`);
+ }
+ const removeSheet = sheets[sheetId];
+ const removeIndex = config.sheetOrder.findIndex((id) => id === sheetId);
+ delete sheets[sheetId];
+
+ if (removeIndex !== config.sheetOrder.length - 1) {
+ sheets[config.sheetOrder[removeIndex + 1]].status = 1;
+ } else {
+ sheets[config.sheetOrder[removeIndex - 1]].status = 1;
+ }
+
+ config.sheetOrder.splice(removeIndex, 1);
+ iSheets.delete(sheetId);
+
+ return {
+ index: removeIndex,
+ sheet: removeSheet as IWorksheetConfig,
+ };
+}
diff --git a/packages/core/src/Sheets/Apply/SetBorder.ts b/packages/core/src/Sheets/Apply/SetBorder.ts
index 4ac2add832..137a766ff7 100644
--- a/packages/core/src/Sheets/Apply/SetBorder.ts
+++ b/packages/core/src/Sheets/Apply/SetBorder.ts
@@ -1,6 +1,7 @@
import { Styles } from '../Domain';
import { ICellData, IStyleData } from '../../Interfaces';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared';
+import { BorderStyleData, CommandUnit } from '../../Command';
/**
*
@@ -30,3 +31,27 @@ export function SetBorder(
});
return result.toJSON();
}
+
+export function SetBorderApply(
+ unit: CommandUnit,
+ data: BorderStyleData
+): ObjectMatrixPrimitiveType<IStyleData> {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const globalStyles = workbook!.getStyles();
+ const matrix = worksheet.getCellMatrix();
+ const wrapper = new ObjectMatrix(data.styles);
+
+ const result = new ObjectMatrix<IStyleData>();
+ wrapper.forValue((row, column, value) => {
+ const cell = matrix.getValue(row, column);
+ if (cell) {
+ const old = globalStyles.get(cell.s);
+ if (old) {
+ result.setValue(row, column, old);
+ }
+ cell.s = globalStyles.setValue(value);
+ }
+ });
+ return result.toJSON();
+}
diff --git a/packages/core/src/Sheets/Apply/SetColumnHide.ts b/packages/core/src/Sheets/Apply/SetColumnHide.ts
index 651ddfc74f..48af48b7ec 100644
--- a/packages/core/src/Sheets/Apply/SetColumnHide.ts
+++ b/packages/core/src/Sheets/Apply/SetColumnHide.ts
@@ -1,4 +1,5 @@
import { ColumnManager } from '../Domain/ColumnManager';
+import { CommandUnit, ISetColumnShowActionData } from '../../Command';
/**
*
@@ -18,3 +19,18 @@ export function SetColumnHide(
column.hd = 1;
}
}
+
+export function SetColumnHideApply(
+ unit: CommandUnit,
+ data: ISetColumnShowActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const columnIndex = data.columnIndex;
+ const columnCount = data.columnCount;
+ const columnManager = worksheet.getColumnManager();
+ for (let i = columnIndex; i < columnIndex + columnCount; i++) {
+ const column = columnManager.getColumnOrCreate(i);
+ column.hd = 1;
+ }
+}
diff --git a/packages/core/src/Sheets/Apply/SetColumnShow.ts b/packages/core/src/Sheets/Apply/SetColumnShow.ts
index aa05bb8c25..eec28fe2bd 100644
--- a/packages/core/src/Sheets/Apply/SetColumnShow.ts
+++ b/packages/core/src/Sheets/Apply/SetColumnShow.ts
@@ -1,4 +1,5 @@
import { ColumnManager } from '../Domain/ColumnManager';
+import { CommandUnit, ISetColumnShowActionData } from '../../Command';
/**
*
@@ -20,3 +21,21 @@ export function SetColumnShow(
}
}
}
+
+export function SetColumnShowApply(
+ unit: CommandUnit,
+ data: ISetColumnShowActionData
+): void {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId);
+ const columnIndex = 0;
+ const columnCount = 0;
+ const columnManager = worksheet!.getColumnManager();
+
+ for (let i = columnIndex; i < columnIndex + columnCount; i++) {
+ const column = columnManager.getColumn(i);
+ if (column) {
+ column.hd = 0;
+ }
+ }
+}
diff --git a/packages/core/src/Sheets/Apply/SetColumnWidth.ts b/packages/core/src/Sheets/Apply/SetColumnWidth.ts
index 6603df635c..190bc0ffda 100644
--- a/packages/core/src/Sheets/Apply/SetColumnWidth.ts
+++ b/packages/core/src/Sheets/Apply/SetColumnWidth.ts
@@ -1,4 +1,5 @@
import { ColumnManager } from '../Domain/ColumnManager';
+import { CommandUnit, ISetColumnWidthActionData } from '../../Command';
/**
*
@@ -22,3 +23,22 @@ export function SetColumnWidth(
}
return result;
}
+
+export function SetColumnWidthApply(
+ unit: CommandUnit,
+ data: ISetColumnWidthActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId);
+ const columnIndex = data.columnIndex;
+ const columnWidth = data.columnWidth;
+ const columnManager = worksheet!.getColumnManager();
+
+ const result: number[] = [];
+ for (let i = columnIndex; i < columnIndex + columnWidth.length; i++) {
+ const column = columnManager.getColumnOrCreate(i);
+ result[i - columnIndex] = column.w;
+ column.w = columnWidth[i - columnIndex];
+ }
+ return result;
+}
diff --git a/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts b/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts
index 12ea915453..2809acaa09 100644
--- a/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts
+++ b/packages/core/src/Sheets/Apply/SetHiddenGridlines.ts
@@ -1,4 +1,5 @@
import { Worksheet } from '../Domain/Worksheet';
+import { CommandUnit, ISetHiddenGridlinesActionData } from '../../Command';
/**
*
@@ -28,3 +29,28 @@ export function SetHiddenGridlines(
// return old sheet name to undo
return oldStatus;
}
+
+export function SetHiddenGridlinesApply(
+ unit: CommandUnit,
+ data: ISetHiddenGridlinesActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const hideGridlines = data.hideGridlines;
+
+ // get config
+ const config = worksheet.getConfig();
+
+ // store old sheet name
+ const oldStatus = config.showGridlines === 0;
+
+ // set new sheet name
+ if (hideGridlines) {
+ config.showGridlines = 0;
+ } else {
+ config.showGridlines = 1;
+ }
+
+ // return old sheet name to undo
+ return oldStatus;
+}
diff --git a/packages/core/src/Sheets/Apply/SetHideRows.ts b/packages/core/src/Sheets/Apply/SetHideRows.ts
index 0d2fee4019..197c68e355 100644
--- a/packages/core/src/Sheets/Apply/SetHideRows.ts
+++ b/packages/core/src/Sheets/Apply/SetHideRows.ts
@@ -1,4 +1,5 @@
import { RowManager } from '../Domain/RowManager';
+import { CommandUnit, ISetRowHideActionData } from '../../Command';
/**
*
@@ -20,3 +21,18 @@ export function SetHideRow(
}
}
}
+
+export function SetHideRowApply(unit: CommandUnit, data: ISetRowHideActionData) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const rowIndex = data.rowIndex;
+ const rowCount = data.rowCount;
+ const rowManager = worksheet.getRowManager();
+
+ for (let i = rowIndex; i < rowIndex + rowCount; i++) {
+ const row = rowManager.getRowOrCreate(i);
+ if (row) {
+ row.hd = 1;
+ }
+ }
+}
diff --git a/packages/core/src/Sheets/Apply/SetNamedRange.ts b/packages/core/src/Sheets/Apply/SetNamedRange.ts
index fc0fd8a9b5..35009c499e 100644
--- a/packages/core/src/Sheets/Apply/SetNamedRange.ts
+++ b/packages/core/src/Sheets/Apply/SetNamedRange.ts
@@ -1,4 +1,5 @@
import { INamedRange } from '../../Interfaces/INamedRange';
+import { CommandUnit, ISetNamedRangeActionData } from '../../Command';
export function SetNamedRange(
namedRanges: INamedRange[],
@@ -13,3 +14,21 @@ export function SetNamedRange(
return null;
})!;
}
+
+export function SetNamedRangeApply(
+ unit: CommandUnit,
+ data: ISetNamedRangeActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const namedRange = data.namedRange;
+ const namedRanges = workbook!.getConfig().namedRanges;
+ return namedRanges.find((currentNamedRange: INamedRange, i) => {
+ if (currentNamedRange.namedRangeId === namedRange.namedRangeId) {
+ // edit
+ namedRanges[i] = namedRange;
+ return currentNamedRange;
+ }
+ return null;
+ })!;
+}
diff --git a/packages/core/src/Sheets/Apply/SetRangeData.ts b/packages/core/src/Sheets/Apply/SetRangeData.ts
index 89bb043d1c..0123f71017 100644
--- a/packages/core/src/Sheets/Apply/SetRangeData.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeData.ts
@@ -3,6 +3,7 @@ import { ICellData, ICopyToOptionsData, IStyleData } from '../../Interfaces';
import { Nullable, Tools } from '../../Shared';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';
import { mergeStyle, transformStyle } from './SetRangeStyle';
+import { CommandUnit, ISetRangeDataActionData } from '../../Command';
/**
*
@@ -109,3 +110,99 @@ export function SetRangeData(
});
return result.getData();
}
+
+export function SetRangeDataApply(unit: CommandUnit, data: ISetRangeDataActionData) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const cellMatrix = worksheet.getCellMatrix();
+ const options = data.options;
+ const addMatrix = data.cellValue;
+ const styles = workbook!.getStyles();
+
+ const target = new ObjectMatrix(addMatrix);
+ const result = new ObjectMatrix<ICellData>();
+
+ if (options) {
+ target.forValue((r, c, value) => {
+ const cell = cellMatrix.getValue(r, c);
+ const newCell: ICellData = {};
+
+ if (options.contentsOnly) {
+ newCell.m = cell?.m;
+ newCell.v = cell?.v;
+ }
+
+ if (options.formatOnly) {
+ // newCell.f = cell?.f;
+ newCell.v = cell?.v;
+ newCell.m = cell?.m;
+ }
+
+ result.setValue(r, c, newCell || {});
+
+ cellMatrix.setValue(r, c, value || {});
+ });
+
+ return result.getData();
+ }
+ target.forValue((r, c, value) => {
+ const cell = cellMatrix.getValue(r, c) || {};
+
+ // set null, clear cell
+ if (!value) {
+ cellMatrix.setValue(r, c, value);
+ result.setValue(r, c, cell);
+ } else {
+ // update style
+
+ // use null to clear style
+ const old = styles.getStyleByCell(cell);
+
+ // store old data
+ const oldCellStyle = transformStyle(
+ old,
+ value?.s as Nullable<IStyleData>
+ );
+ const oldCellData = Tools.deepClone(cell);
+ oldCellData.s = oldCellStyle;
+
+ result.setValue(r, c, oldCellData);
+
+ if (old == null) {
+ // clear
+ delete cell.s;
+ }
+
+ // set style
+ const merge = mergeStyle(old, value?.s as Nullable<IStyleData>);
+
+ // then remove null
+ merge && Tools.removeNull(merge);
+
+ if (Tools.isEmptyObject(merge)) {
+ delete cell.s;
+ } else {
+ cell.s = styles.setValue(merge);
+ }
+
+ // update other value TODO: move
+ // if (value.p != null) {
+ // cell.p = value.p;
+ // }
+ if (value.v != null) {
+ cell.v = value.v;
+ }
+ if (value.m != null) {
+ cell.m = value.m;
+ } else {
+ cell.m = String(cell.v);
+ }
+ if (value.t != null) {
+ cell.t = value.t;
+ }
+
+ cellMatrix.setValue(r, c, cell);
+ }
+ });
+ return result.getData();
+}
diff --git a/packages/core/src/Sheets/Apply/SetRangeFormat.ts b/packages/core/src/Sheets/Apply/SetRangeFormat.ts
index a22d112f39..0354030b5d 100644
--- a/packages/core/src/Sheets/Apply/SetRangeFormat.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeFormat.ts
@@ -1,6 +1,7 @@
import { ICellData, IRangeData } from '../../Interfaces';
import { Nullable, Tools } from '../../Shared';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';
+import { CommandUnit, ISetRangeFormatActionData } from '../../Command';
/**
* TODO remove tp Format Plugin
@@ -52,3 +53,47 @@ export function SetRangeFormat(
}
return result.getData();
}
+
+export function SetRangeFormatApply(
+ unit: CommandUnit,
+ data: ISetRangeFormatActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const cellMatrix = worksheet.getCellMatrix();
+ const addMatrix = data.cellFormat;
+ const rangeData = data.rangeData;
+
+ const target = new ObjectMatrix(addMatrix);
+ const result = new ObjectMatrix<string>();
+ for (let i = rangeData.startRow; i <= rangeData.endRow; i++) {
+ for (let j = rangeData.startColumn; j <= rangeData.endColumn; j++) {
+ const targetValue = target.getValue(i, j);
+
+ if (targetValue) {
+ const value = JSON.parse(targetValue);
+
+ // store history value
+ const cell: Nullable<ICellData> = cellMatrix.getValue(i, j);
+ // result.setValue(i, j, (cell && JSON.stringify(cell.fm)) || '');
+
+ // update new value, cell may be undefined
+ const cellValue: ICellData = Tools.deepClone(cell || {});
+
+ // cellValue.fm = {
+ // f: value.f,
+ // t: value.t,
+ // };
+
+ cellMatrix.setValue(i, j, cellValue || {});
+ } else {
+ const cell: Nullable<ICellData> = cellMatrix.getValue(i, j);
+ // result.setValue(i, j, (cell && JSON.stringify(cell.fm)) || '');
+ const cellValue: ICellData = Tools.deepClone(cell || {});
+ // delete cellValue.fm;
+ cellMatrix.setValue(i, j, cellValue || {});
+ }
+ }
+ }
+ return result.getData();
+}
diff --git a/packages/core/src/Sheets/Apply/SetRangeFormattedValue.ts b/packages/core/src/Sheets/Apply/SetRangeFormattedValue.ts
index f76ed23f73..d4b1b447b2 100644
--- a/packages/core/src/Sheets/Apply/SetRangeFormattedValue.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeFormattedValue.ts
@@ -1,6 +1,7 @@
import { ICellData, ICellV, IRangeData } from '../../Interfaces';
import { Nullable, Tools } from '../../Shared';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';
+import { CommandUnit, ISetRangeFormattedValueActionData } from '../../Command';
/**
*
@@ -38,3 +39,36 @@ export function SetRangeFormattedValue(
}
return result.getData();
}
+
+export function SetRangeFormattedValueApply(
+ unit: CommandUnit,
+ data: ISetRangeFormattedValueActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const cellMatrix = worksheet.getCellMatrix();
+ const addMatrix = data.cellValue;
+ const rangeData = data.rangeData;
+
+ const target = new ObjectMatrix(addMatrix);
+ const result = new ObjectMatrix<ICellV>();
+ for (let i = rangeData.startRow; i <= rangeData.endRow; i++) {
+ for (let j = rangeData.startColumn; j <= rangeData.endColumn; j++) {
+ const value = target.getValue(i, j);
+
+ // store history value
+ const cell: Nullable<ICellData> = cellMatrix.getValue(i, j);
+ result.setValue(i, j, (cell && cell.v) || '');
+
+ // update new value, cell may be undefined
+ const cellValue = Tools.deepClone(cell || {});
+ cellValue.v = value;
+ // TODO:calculate m from cell format
+ // TODO:解析外移,性能监测
+ cellValue.m = `${value}`;
+
+ cellMatrix.setValue(i, j, cellValue || {});
+ }
+ }
+ return result.getData();
+}
diff --git a/packages/core/src/Sheets/Apply/SetRangeFormula.ts b/packages/core/src/Sheets/Apply/SetRangeFormula.ts
index 4b3ec2357a..54073a161f 100644
--- a/packages/core/src/Sheets/Apply/SetRangeFormula.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeFormula.ts
@@ -1,6 +1,7 @@
import { ICellData, IRangeData } from '../../Interfaces';
import { Nullable, Tools } from '../../Shared';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';
+import { CommandUnit, ISetRangeFormulaActionData } from '../../Command';
/**
* TODO remove tp Formula Plugin
@@ -40,3 +41,34 @@ export function SetRangeFormula(
}
return result.getData();
}
+
+export function SetRangeFormulaApply(
+ unit: CommandUnit,
+ data: ISetRangeFormulaActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const cellMatrix = worksheet.getCellMatrix();
+ const addMatrix = data.cellFormula;
+ const rangeData = data.rangeData;
+
+ const target = new ObjectMatrix(addMatrix);
+ const result = new ObjectMatrix<string>();
+ for (let i = rangeData.startRow; i <= rangeData.endRow; i++) {
+ for (let j = rangeData.startColumn; j <= rangeData.endColumn; j++) {
+ const value = target.getValue(i, j);
+
+ // store history value
+ const cell: Nullable<ICellData> = cellMatrix.getValue(i, j);
+ // result.setValue(i, j, (cell && cell.f) || '');
+
+ // update new value, cell may be undefined
+ const cellValue = Tools.deepClone(cell || {});
+
+ cellValue.f = value;
+
+ cellMatrix.setValue(i, j, cellValue || {});
+ }
+ }
+ return result.getData();
+}
diff --git a/packages/core/src/Sheets/Apply/SetRangeNote.ts b/packages/core/src/Sheets/Apply/SetRangeNote.ts
index 18dcab4cec..a4cc2a1df8 100644
--- a/packages/core/src/Sheets/Apply/SetRangeNote.ts
+++ b/packages/core/src/Sheets/Apply/SetRangeNote.ts
@@ -1,6 +1,7 @@
import { ICellData, IRangeData } from '../../Interfaces';
import { Nullable, Tools } from '../../Shared';
import { ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared/ObjectMatrix';
+import { CommandUnit, ISetRangeNoteActionData } from '../../Command';
/**
*
@@ -36,3 +37,34 @@ export function SetRangeNote(
}
return result.getData();
}
+
+export function SetRangeNoteApply(
+ unit: CommandUnit,
+ data: ISetRangeNoteActionData
+): ObjectMatrixPrimitiveType<string> {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const cellMatrix = worksheet.getCellMatrix();
+ const addMatrix = data.cellNote;
+ const rangeData = data.rangeData;
+
+ const target = new ObjectMatrix(addMatrix);
+ const result = new ObjectMatrix<string>();
+ for (let i = rangeData.startRow; i <= rangeData.endRow; i++) {
+ for (let j = rangeData.startColumn; j <= rangeData.endColumn; j++) {
+ const value = target.getValue(i, j);
+
+ // store history value
+ const cell: Nullable<ICellData> = cellMatrix.getValue(i, j);
+ // result.setValue(i, j, (cell && cell.n) || '');
+
+ // update new value, cell may be undefined
+ const cellValue = Tools.deepClone(cell || {});
+
+ cellValue.n = value;
+
+ cellMatrix.setValue(i, j, cellValue || {});
+ }
+ }
+ return result.getData();
+}
diff --git a/packages/core/src/Sheets/Apply/SetRightToLeft.ts b/packages/core/src/Sheets/Apply/SetRightToLeft.ts
index 2e4f776038..d06fecaa09 100644
--- a/packages/core/src/Sheets/Apply/SetRightToLeft.ts
+++ b/packages/core/src/Sheets/Apply/SetRightToLeft.ts
@@ -1,5 +1,6 @@
-import { Worksheet } from '../Domain/Worksheet';
+import { Worksheet } from '../Domain';
import { BooleanNumber } from '../../Enum';
+import { CommandUnit, ISetRightToLeftActionData } from '../../Command';
/**
*
@@ -25,3 +26,24 @@ export function SetRightToLeft(
// return old sheet name to undo
return oldState;
}
+
+export function SetRightToLeftApply(
+ unit: CommandUnit,
+ data: ISetRightToLeftActionData
+) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId)!;
+ const rightToLeft = data.rightToLeft;
+
+ // get config
+ const config = worksheet.getConfig();
+
+ // store old sheet name
+ const oldState = config.rightToLeft;
+
+ // set new sheet name
+ config.rightToLeft = rightToLeft;
+
+ // return old sheet name to undo
+ return oldState;
+}
diff --git a/packages/core/src/Sheets/Apply/SetRowHeight.ts b/packages/core/src/Sheets/Apply/SetRowHeight.ts
index 944eb79f1c..91804ab3f8 100644
--- a/packages/core/src/Sheets/Apply/SetRowHeight.ts
+++ b/packages/core/src/Sheets/Apply/SetRowHeight.ts
@@ -1,4 +1,5 @@
-import { RowManager } from '../Domain/RowManager';
+import { RowManager } from '../Domain';
+import { CommandUnit, ISetRowHeightActionData } from '../../Command';
/**
*
@@ -22,3 +23,19 @@ export function SetRowHeight(
}
return result;
}
+
+export function SetRowHeightApply(unit: CommandUnit, data: ISetRowHeightActionData) {
+ const workbook = unit.WorkBookUnit;
+ const worksheet = workbook!.getSheetBySheetId(data.sheetId);
+ const rowIndex = data.rowIndex;
+ const rowHeight = data.rowHeight;
+ const rowManager = worksheet!.getRowManager();
+
+ const result: number[] = [];
+ for (let i = rowIndex; i < rowIndex + rowHeight.length; i++) {
+ const row = rowManager.getRowOrCreate(i);
+ result[i - rowIndex] = row.h;
+ row.h = rowHeight[i - rowIndex];
+ }
+ return result;
+}
diff --git a/packages/core/src/Sheets/Apply/SetWorkSheetName.ts b/packages/core/src/Sheets/Apply/SetWorkSheetName.ts
index 27fb690e29..02dd2918ce 100644
--- a/packages/core/src/Sheets/Apply/SetWorkSheetName.ts
+++ b/packages/core/src/Sheets/Apply/SetWorkSheetName.ts
@@ -1,4 +1,4 @@
-import { Worksheet } from '../Domain/Worksheet';
+import { Worksheet } from '../Domain';
/**
*
@@ -21,3 +21,5 @@ export function SetWorkSheetName(worksheet: Worksheet, sheetName: string): strin
// return old sheet name to undo
return oldSheetName;
}
+
+export function SetWorkSheetNameApply() {}