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.

chore(core): clear range api

Dushusir9c8ab01beabd
diff --git a/packages/core/src/Command/RegisterAction.ts b/packages/core/src/Command/RegisterAction.ts
index 72e407bf19..c7f63ad823 100644
--- a/packages/core/src/Command/RegisterAction.ts
+++ b/packages/core/src/Command/RegisterAction.ts
@@ -1,7 +1,6 @@
import {
AddMergeAction,
AddNamedRangeAction,
- ClearRangeAction,
DeleteNamedRangeAction,
DeleteRangeAction,
InsertColumnAction,
@@ -82,7 +81,6 @@ CommandManager.register(
SetRangeFormattedValueAction
);
CommandManager.register(DeleteRangeAction.NAME, DeleteRangeAction);
-CommandManager.register(ClearRangeAction.NAME, ClearRangeAction);
CommandManager.register(InsertRangeAction.NAME, InsertRangeAction);
CommandManager.register(SetTabColorAction.NAME, SetTabColorAction);
CommandManager.register(SetWorkSheetHideAction.NAME, SetWorkSheetHideAction);
diff --git a/packages/core/src/Sheets/Apply/ClearRange.ts b/packages/core/src/Sheets/Apply/ClearRange.ts
index 4c3a4b25fc..07b3204aa0 100644
--- a/packages/core/src/Sheets/Apply/ClearRange.ts
+++ b/packages/core/src/Sheets/Apply/ClearRange.ts
@@ -1,52 +1,9 @@
-import { ICellData, IOptionData, IRangeData } from '../../Interfaces';
-import { Tools, ObjectMatrix, ObjectMatrixPrimitiveType } from '../../Shared';
+import { ICellData } from '../../Interfaces';
+import { Tools, ObjectMatrix } from '../../Shared';
import { CommandUnit } from '../../Command';
import { IClearRangeActionData } from '../Action';
-/**
- *
- * @param cellMatrix
- * @param options
- * @param rangeData
- * @returns
- *
- * @internal
- */
-export function ClearRange(
- cellMatrix: ObjectMatrix<ICellData>,
- options: IOptionData,
- rangeData: IRangeData
-): ObjectMatrixPrimitiveType<ICellData> {
- const { startRow, endRow, startColumn, endColumn } = rangeData;
-
- const rows = endRow - startRow + 1;
- const columns = endColumn - startColumn + 1;
-
- const result = new ObjectMatrix<ICellData>();
- // build new data
- for (let r = startRow; r <= endRow; r++) {
- for (let c = startColumn; c <= endColumn; c++) {
- // get current value
- const value = cellMatrix.getValue(r, c);
- result.setValue(r, c, Tools.deepClone(value as ICellData));
- if (value) {
- if (options.formatOnly) {
- delete value.s;
- }
- if (options.contentsOnly) {
- value.v = '';
- value.m = '';
- }
-
- cellMatrix.setValue(r, c, Tools.deepClone(value as ICellData));
- }
- }
- }
-
- return result.getData();
-}
-
export function ClearRangeApply(unit: CommandUnit, data: IClearRangeActionData) {
const worksheet = unit.WorkBookUnit?.getSheetBySheetId(data.sheetId);
const cellMatrix = worksheet?.getCellMatrix();