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(numfmt): text format excel, default format (#4669)

Dushusir72411b96fa25
diff --git a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts
index c5b48d9c38..7bd9ec9c75 100644
--- a/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts
+++ b/e2e/visual-comparison/sheets/sheets-visual-comparison.spec.ts
@@ -261,7 +261,7 @@ test('diff set text format number cell', async () => {
{
row: 0,
col: 7,
- pattern: '@@@',
+ pattern: '@',
type: 'text',
},
],
@@ -276,7 +276,7 @@ test('diff set text format number cell', async () => {
{
row: 0,
col: 8,
- pattern: '@@@',
+ pattern: '@',
type: 'text',
},
],
diff --git a/packages/engine-formula/src/engine/reference-object/base-reference-object.ts b/packages/engine-formula/src/engine/reference-object/base-reference-object.ts
index 2e5e88b0e8..05dda233c3 100644
--- a/packages/engine-formula/src/engine/reference-object/base-reference-object.ts
+++ b/packages/engine-formula/src/engine/reference-object/base-reference-object.ts
@@ -19,7 +19,7 @@ import type { IRuntimeUnitDataType, IUnitData, IUnitSheetNameMap, IUnitStylesDat
import type { BaseValueObject, IArrayValueObject } from '../value-object/base-value-object';
import { CellValueType, moveRangeByOffset } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import { FormulaAstLRU } from '../../basics/cache-lru';
import { ERROR_TYPE_SET, ErrorType } from '../../basics/error-type';
import { isNullCellForFormula } from '../../basics/is-null-cell';
@@ -405,7 +405,7 @@ export class BaseReferenceObject extends ObjectClassType {
if (cell.t === CellValueType.NUMBER) {
const pattern = this._getPatternByCell(cell);
- if (pattern === DEFAULT_TEXT_FORMAT) {
+ if (isTextFormat(pattern)) {
return StringValueObject.create(value.toString());
}
diff --git a/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts b/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts
index 595f772a41..2aca1409ba 100644
--- a/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts
+++ b/packages/engine-formula/src/engine/utils/__tests__/numfmt-kit.spec.ts
@@ -15,8 +15,8 @@
*/
import { describe, expect, it } from 'vitest';
-import { compareNumfmtPriority, comparePatternPriority } from '../numfmt-kit';
import { operatorToken } from '../../../basics/token';
+import { compareNumfmtPriority, comparePatternPriority } from '../numfmt-kit';
const numfmtMap = {
currency: '"¥"#,##0.00_);[Red]("¥"#,##0.00)',
@@ -28,7 +28,7 @@ const numfmtMap = {
number: '0',
percent: '0%',
scientific: '0.00E+00',
- text: '@@@',
+ text: '@',
time: 'am/pm h":"mm":"ss',
unknown: '#,##0',
accounting: '_("¤"* #,##0.000_)',
diff --git a/packages/engine-numfmt/src/const.ts b/packages/engine-numfmt/src/const.ts
index bd62d34eed..837036610f 100644
--- a/packages/engine-numfmt/src/const.ts
+++ b/packages/engine-numfmt/src/const.ts
@@ -14,4 +14,6 @@
* limitations under the License.
*/
-export const DEFAULT_TEXT_FORMAT = '@@@';
+export const DEFAULT_TEXT_FORMAT = '@@@'; // Compatible with old data
+export const DEFAULT_TEXT_FORMAT_EXCEL = '@'; // The default text format in Excel, recommended
+export const DEFAULT_NUMBER_FORMAT = 'General'; // null or General are considered the default format
diff --git a/packages/engine-numfmt/src/index.ts b/packages/engine-numfmt/src/index.ts
index 367703025e..96b5f561f1 100644
--- a/packages/engine-numfmt/src/index.ts
+++ b/packages/engine-numfmt/src/index.ts
@@ -14,4 +14,5 @@
* limitations under the License.
*/
-export { DEFAULT_TEXT_FORMAT } from './const';
+export { DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL } from './const';
+export { isDefaultFormat, isTextFormat } from './util';
diff --git a/packages/engine-numfmt/src/util.ts b/packages/engine-numfmt/src/util.ts
new file mode 100644
index 0000000000..2a2b0d5383
--- /dev/null
+++ b/packages/engine-numfmt/src/util.ts
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2023-present DreamNum Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL } from './const';
+
+export function isTextFormat(pattern: string | undefined) {
+ return pattern === DEFAULT_TEXT_FORMAT || pattern === DEFAULT_TEXT_FORMAT_EXCEL;
+}
+
+export function isDefaultFormat(pattern: string | undefined | null) {
+ return pattern === null || pattern === undefined || pattern === DEFAULT_NUMBER_FORMAT;
+}
diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.ts b/packages/sheets-numfmt-ui/src/controllers/menu.ts
index 9227c1cacc..3def959690 100644
--- a/packages/sheets-numfmt-ui/src/controllers/menu.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/menu.ts
@@ -17,7 +17,7 @@
import type { IAccessor } from '@univerjs/core';
import type { IMenuSelectorItem } from '@univerjs/ui';
import { ICommandService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { DEFAULT_TEXT_FORMAT_EXCEL, isDefaultFormat } from '@univerjs/engine-numfmt';
import {
RangeProtectionPermissionEditPoint,
RemoveNumfmtMutation,
@@ -41,7 +41,7 @@ export const MENU_OPTIONS: Array<{ label: string; pattern: string | null } | '|'
},
{
label: 'sheet.numfmt.text',
- pattern: DEFAULT_TEXT_FORMAT,
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
'|',
{
@@ -186,6 +186,12 @@ export const FactoryOtherMenuItem = (accessor: IAccessor): IMenuSelectorItem =>
const pattern = numfmtValue?.pattern;
let value: string = localeService.t('sheet.numfmt.general');
+ // Adapts the 'General' obtained during import, or the 'General' set manually
+ if (isDefaultFormat(pattern)) {
+ subscribe.next(value);
+ return;
+ }
+
if (pattern) {
const item = MENU_OPTIONS.filter((item) => typeof item === 'object' && item.pattern).find(
(item) => isPatternEqualWithoutDecimal(pattern, (item as { pattern: string }).pattern)
diff --git a/packages/sheets-numfmt-ui/src/controllers/numfmt-alert-render.controller.ts b/packages/sheets-numfmt-ui/src/controllers/numfmt-alert-render.controller.ts
index 34e1a51f57..fc0eaca4f3 100644
--- a/packages/sheets-numfmt-ui/src/controllers/numfmt-alert-render.controller.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/numfmt-alert-render.controller.ts
@@ -18,7 +18,7 @@ import type { Workbook } from '@univerjs/core';
import type { IRenderContext, IRenderModule } from '@univerjs/engine-render';
import { Disposable, Inject, isRealNum, LocaleService } from '@univerjs/core';
import { FormulaDataModel } from '@univerjs/engine-formula';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import { INumfmtService } from '@univerjs/sheets';
import { CellAlertManagerService, CellAlertType, HoverManagerService } from '@univerjs/sheets-ui';
import { IZenZoneService } from '@univerjs/ui';
@@ -76,7 +76,7 @@ export class NumfmtAlertRenderController extends Disposable implements IRenderMo
}
// Preventing blank object
- if (numfmtValue.pattern === DEFAULT_TEXT_FORMAT && cellData?.v && isRealNum(cellData.v)) {
+ if (isTextFormat(numfmtValue.pattern) && cellData?.v && isRealNum(cellData.v)) {
const currentAlert = this._cellAlertManagerService.currentAlert.get(ALERT_KEY);
const currentLoc = currentAlert?.alert?.location;
if (
diff --git a/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts b/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts
index bb361f279d..032b0a0256 100644
--- a/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/numfmt.editor.controller.ts
@@ -32,7 +32,7 @@ import {
toDisposable,
UniverInstanceType,
} from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import {
AFTER_CELL_EDIT,
BEFORE_CELL_EDIT,
@@ -170,7 +170,7 @@ export class NumfmtEditorController extends Disposable {
}
// if the cell is text format or force string, do not convert the value
- if (currentNumfmtValue?.pattern === DEFAULT_TEXT_FORMAT || value.t === CellValueType.FORCE_STRING) {
+ if (isTextFormat(currentNumfmtValue?.pattern) || value.t === CellValueType.FORCE_STRING) {
return next(value);
}
diff --git a/packages/sheets-numfmt/src/commands/commands/set-numfmt.command.ts b/packages/sheets-numfmt/src/commands/commands/set-numfmt.command.ts
index bc92a8e09d..f473ca721b 100644
--- a/packages/sheets-numfmt/src/commands/commands/set-numfmt.command.ts
+++ b/packages/sheets-numfmt/src/commands/commands/set-numfmt.command.ts
@@ -29,7 +29,7 @@ import { CellValueType,
IUniverInstanceService,
ObjectMatrix,
sequenceExecute } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import {
checkCellValueType,
factoryRemoveNumfmtUndoMutation,
@@ -82,7 +82,7 @@ export const SetNumfmtCommand: ICommand<ISetNumfmtCommandParams> = {
const undos: Array<IMutationInfo<IRemoveNumfmtMutationParams | ISetNumfmtMutationParams | ISetRangeValuesMutationParams>> = [];
if (setCells.length) {
const setCellTypeObj = setCells.reduce((pre, cur) => {
- if (cur.pattern === DEFAULT_TEXT_FORMAT) {
+ if (isTextFormat(cur.pattern)) {
pre.setValue(cur.row, cur.col, { t: CellValueType.STRING });
}
const cell = worksheet.getCellRaw(cur.row, cur.col);
diff --git a/packages/sheets-numfmt/src/controllers/numfmt-cell-content.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt-cell-content.controller.ts
index 27a838ee14..12ed9f6dc3 100644
--- a/packages/sheets-numfmt/src/controllers/numfmt-cell-content.controller.ts
+++ b/packages/sheets-numfmt/src/controllers/numfmt-cell-content.controller.ts
@@ -35,7 +35,7 @@ import {
ThemeService,
UniverInstanceType,
} from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import { checkCellValueType, InterceptCellContentPriority, INTERCEPTOR_POINT, INumfmtService, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService } from '@univerjs/sheets';
import { BehaviorSubject, merge, of, skip, switchMap } from 'rxjs';
import { getPatternPreviewIgnoreGeneral } from '../utils/pattern';
@@ -134,7 +134,7 @@ export class SheetsNumfmtCellContentController extends Disposable {
}
// Add error marker to text format number
- if (numfmtValue.pattern === DEFAULT_TEXT_FORMAT) {
+ if (isTextFormat(numfmtValue.pattern)) {
return next({
...cell,
t: CellValueType.STRING,
diff --git a/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts b/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
index 3f1b494820..1ab0106f01 100644
--- a/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
+++ b/packages/sheets-ui/src/controllers/editor/__tests__/end-edit.controller.spec.ts
@@ -18,6 +18,7 @@ import type { ICellData, IDocumentData, Univer, Workbook } from '@univerjs/core'
import type { IFunctionService } from '@univerjs/engine-formula';
import { CellValueType, IConfigService, IContextService, Injector, LocaleService, LocaleType, Tools } from '@univerjs/core';
import { LexerTreeBuilder } from '@univerjs/engine-formula';
+import { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/engine-numfmt';
import { SpreadsheetSkeleton } from '@univerjs/engine-render';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { normalizeString } from '../../utils/char-tools';
@@ -168,7 +169,7 @@ describe('Test EndEditController', () => {
const cell: ICellData = {
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
t: null,
@@ -184,7 +185,7 @@ describe('Test EndEditController', () => {
t: CellValueType.STRING,
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
f: null,
@@ -200,7 +201,7 @@ describe('Test EndEditController', () => {
const cell: ICellData = {
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
t: null,
@@ -216,7 +217,7 @@ describe('Test EndEditController', () => {
t: CellValueType.STRING,
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
f: null,
@@ -232,7 +233,7 @@ describe('Test EndEditController', () => {
const cell: ICellData = {
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
t: null,
@@ -248,7 +249,7 @@ describe('Test EndEditController', () => {
t: CellValueType.STRING,
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
f: null,
@@ -264,7 +265,7 @@ describe('Test EndEditController', () => {
const cell: ICellData = {
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
t: 1,
@@ -320,7 +321,7 @@ describe('Test EndEditController', () => {
t: CellValueType.STRING,
s: {
n: {
- pattern: '@@@',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
f: null,
diff --git a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
index 5e3a8cadec..51272f41e6 100644
--- a/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
+++ b/packages/sheets-ui/src/controllers/editor/editing.render-controller.ts
@@ -47,7 +47,7 @@ import {
} from '@univerjs/docs';
import { VIEWPORT_KEY as DOC_VIEWPORT_KEY, DocSelectionRenderService, IEditorService, MoveCursorOperation, MoveSelectionOperation, ReplaceSnapshotCommand } from '@univerjs/docs-ui';
import { IFunctionService, LexerTreeBuilder, matchToken } from '@univerjs/engine-formula';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
import {
convertTextRotation,
@@ -781,9 +781,9 @@ export function getCellDataByInput(
cellData.p = snapshot;
cellData.t = CellValueType.STRING;
}
- // Text format ('@@@') has the highest priority
- else if (cellData.s && styles?.get(cellData.s)?.n?.pattern === DEFAULT_TEXT_FORMAT) {
- // If the style is text format ('@@@'), the data should be set as a string.
+ // Text format ('@' or '@@@') has the highest priority
+ else if (cellData.s && isTextFormat(styles?.get(cellData.s)?.n?.pattern)) {
+ // If the style is text format ('@'or '@@@'), the data should be set as a string.
cellData.v = newDataStream;
cellData.f = null;
cellData.si = null;
diff --git a/packages/sheets/src/basics/cell-type.ts b/packages/sheets/src/basics/cell-type.ts
index 2ca3b6c68b..85a28e6184 100644
--- a/packages/sheets/src/basics/cell-type.ts
+++ b/packages/sheets/src/basics/cell-type.ts
@@ -16,7 +16,7 @@
import type { CellValue, ICellData, IStyleData, Nullable, Styles } from '@univerjs/core';
import { CellValueType, isBooleanString, isRealNum } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { isTextFormat } from '@univerjs/engine-numfmt';
/**
* Get cell value type by style, new value and old value.
@@ -36,7 +36,7 @@ export function getCellType(styles: Styles, newVal: ICellData, oldVal: ICellData
// For cells with forced strings, set the percentage format and still use forced strings
// For cells with forced strings, update to the number and convert to ordinary numbers
// For cells with forced strings and text formats, update to the number and still use forced strings
- if (!isTextFormat(oldStyle) && newVal.v !== undefined) {
+ if (!isTextFormat(oldStyle?.n?.pattern) && newVal.v !== undefined) {
if (isRealNum(newVal.v)) {
return CellValueType.NUMBER;
} else if (isBooleanString(`${newVal.v}`)) {
@@ -49,7 +49,7 @@ export function getCellType(styles: Styles, newVal: ICellData, oldVal: ICellData
// For cells with ordinary numbers, set the text format and convert the cell type to text
if (hasNumberFormat(newStyle)) {
- if (isTextFormat(newStyle)) {
+ if (isTextFormat(newStyle?.n?.pattern)) {
return CellValueType.STRING;
}
@@ -57,7 +57,7 @@ export function getCellType(styles: Styles, newVal: ICellData, oldVal: ICellData
}
// For cells with text format, the cell type is still text when numbers are written, because the ISNUMBER function detects FALSE
- if (isTextFormat(oldStyle)) {
+ if (isTextFormat(oldStyle?.n?.pattern)) {
return CellValueType.STRING;
}
@@ -72,10 +72,6 @@ function hasNumberFormat(style: Nullable<IStyleData>) {
return !!style?.n?.pattern;
}
-function isTextFormat(style: Nullable<IStyleData>) {
- return style?.n?.pattern === DEFAULT_TEXT_FORMAT;
-}
-
/**
* Get the correct type after setting values to a cell.
*
@@ -119,7 +115,7 @@ export function getCellTypeByPattern(cell: ICellData, pattern: string) {
return CellValueType.FORCE_STRING;
}
- if (pattern === DEFAULT_TEXT_FORMAT) {
+ if (isTextFormat(pattern)) {
return CellValueType.STRING;
}
diff --git a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts
index f7fa678b13..bd160ff140 100644
--- a/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts
+++ b/packages/sheets/src/commands/commands/__tests__/set-range-values.command.spec.ts
@@ -28,7 +28,7 @@ import {
UndoCommand,
UniverInstanceType,
} from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/engine-numfmt';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { SheetsSelectionsService } from '../../../services/selections/selection.service';
import { SetRangeValuesMutation } from '../../mutations/set-range-values.mutation';
@@ -123,7 +123,7 @@ const getTestWorkbookDataDemo = (): IWorkbookData => ({
s4: { fs: 12 },
s5: {
n: {
- pattern: DEFAULT_TEXT_FORMAT, // text
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL, // text
},
},
},
@@ -895,7 +895,7 @@ describe('Test set range values commands', () => {
it('set value when origin cell has text number format', async () => {
function getParams() {
const params: ISetRangeValuesCommandParams = {
- value: { 0: { 2: { v: '01' }, 3: { v: '0.20' }, 4: { v: '001', t: CellValueType.FORCE_STRING }, 5: { s: { n: { pattern: DEFAULT_TEXT_FORMAT } } } } },
+ value: { 0: { 2: { v: '01' }, 3: { v: '0.20' }, 4: { v: '001', t: CellValueType.FORCE_STRING }, 5: { s: { n: { pattern: DEFAULT_TEXT_FORMAT_EXCEL } } } } },
};
return params;
diff --git a/packages/sheets/src/services/__tests__/numfmt.service.test.ts b/packages/sheets/src/services/__tests__/numfmt.service.test.ts
index 796d90951b..d9e8d07287 100644
--- a/packages/sheets/src/services/__tests__/numfmt.service.test.ts
+++ b/packages/sheets/src/services/__tests__/numfmt.service.test.ts
@@ -17,7 +17,7 @@
import type { Injector, Styles, Univer, Workbook, Worksheet } from '@univerjs/core';
import type { IRemoveNumfmtMutationParams, ISetNumfmtMutationParams } from '@univerjs/sheets';
import { cellToRange, CellValueType, ICommandService, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/engine-numfmt';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { RemoveNumfmtMutation, SetNumfmtMutation } from '../../commands/mutations/numfmt-mutation';
@@ -106,18 +106,18 @@ describe('test numfmt service', () => {
subUnitId,
refMap: {
1: {
- pattern: DEFAULT_TEXT_FORMAT,
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
},
},
values: { 1: { ranges: [cellToRange(0, 5)] } },
};
commandService.executeCommand(SetNumfmtMutation.id, params);
const numfmt = numfmtService.getValue(unitId, subUnitId, 0, 5);
- expect(numfmt?.pattern).toEqual(DEFAULT_TEXT_FORMAT);
+ expect(numfmt?.pattern).toEqual(DEFAULT_TEXT_FORMAT_EXCEL);
const cell = sheet.getCellRaw(0, 5);
const numfmtId = cell?.s;
- expect(styles.get(numfmtId)?.n).toEqual({ pattern: DEFAULT_TEXT_FORMAT });
+ expect(styles.get(numfmtId)?.n).toEqual({ pattern: DEFAULT_TEXT_FORMAT_EXCEL });
});
it('model set, text format contains number, to number format', () => {
diff --git a/packages/sheets/src/services/__tests__/util.ts b/packages/sheets/src/services/__tests__/util.ts
index bf5b6c4d2d..092068893c 100644
--- a/packages/sheets/src/services/__tests__/util.ts
+++ b/packages/sheets/src/services/__tests__/util.ts
@@ -16,7 +16,7 @@
import type { Dependency, IWorkbookData, Workbook } from '@univerjs/core';
import { CellValueType, ILogService, Inject, Injector, IUniverInstanceService, LocaleType, LogLevel, Plugin, Univer, UniverInstanceType } from '@univerjs/core';
-import { DEFAULT_TEXT_FORMAT } from '@univerjs/engine-numfmt';
+import { DEFAULT_TEXT_FORMAT_EXCEL } from '@univerjs/engine-numfmt';
export const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
id: 'test',
@@ -72,7 +72,7 @@ export const TEST_WORKBOOK_DATA_DEMO: IWorkbookData = {
styles: {
s5: {
n: {
- pattern: DEFAULT_TEXT_FORMAT, // text
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL, // text
},
},
},