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.

Merge branch 'dev' of https://github.com/dream-num/univer into dev

eiji-the69fc40fe183
diff --cc packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.ts
index e844ec8927,d1ab2cf6ff..dafd2a2d68
--- a/packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.ts
+++ b/packages/sheets-plugin-numfmt/src/NumfmtActionExtensionFactory.ts
@@@ -1,27 -1,24 +1,27 @@@
- import { ACTION_NAMES, Plugin, BaseActionExtension, BaseActionExtensionFactory, IActionData, ISetRangeDataActionData, ObjectMatrix } from '@univer/core';
+ import { ACTION_NAMES, Plugin, BaseActionExtension, BaseActionExtensionFactory, ISetRangeDataActionData, ObjectMatrix, IActionData } from '@univer/core';
import { numfmt } from '@univer/base-numfmt-engine';
+import { ACTION_NAMES as PLUGIN_ACTION_NAMES } from './Const';
export class NumfmtActionExtension extends BaseActionExtension<ISetRangeDataActionData> {
- constructor(protected actionData: ISetRangeDataActionData) {
- super(actionData);
- }
+ // constructor(protected actionData: ISetRangeDataActionData) {
+ // super(actionData);
+ // }
execute() {
- const matrix = new ObjectMatrix(this.actionData.cellValue);
- matrix.forEach((rowNumber, row) => {
- row.forEach((colNumber, cell) => {
- if (cell.v) {
- const result = numfmt.parseValue(cell.v) as { z: string };
- if (result) {
- const format = numfmt(result.z);
- cell.m = format(String(cell.v));
- }
- }
- });
+ const rangeMatrix = new ObjectMatrix(this.actionData.cellValue);
+ const numfmtMatrix = new ObjectMatrix<string>();
+ rangeMatrix.forValue((r, c, cell) => {
+ const result = numfmt.parseValue(cell.v) as { z: string };
+ const patten = result.z || 'General';
+ cell.m = numfmt(patten)(String(cell.v));
+ numfmtMatrix.setValue(r, c, patten);
});
+ const setNumfmtRangeDataAction = {
+ actionName: PLUGIN_ACTION_NAMES.SET_NUMFMT_RANGE_DATA_ACTION,
+ sheetId: this.actionData.sheetId,
+ rangeData: this.actionData.rangeData,
+ cellValue: numfmtMatrix.toJSON(),
+ };
}
}