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.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(numfmt): fix bad case (#6019)
wpxp123456a7620beabb35
diff --git a/packages/core/src/shared/numfmt.ts b/packages/core/src/shared/numfmt.tsindex e8d6aa0b6a..8bdd715cd1 100644--- a/packages/core/src/shared/numfmt.ts+++ b/packages/core/src/shared/numfmt.ts@@ -131,7 +131,7 @@ export const getNumfmtParseValueFilter = (value: string): numfmt.ParseData | nulif (!parseData) return null;- const { z } = parseData;+ const { v, z } = parseData;if (z) {/**@@ -147,6 +147,13 @@ export const getNumfmtParseValueFilter = (value: string): numfmt.ParseData | nul* '5:00 AM' => 'h:mm AM/PM' ----- correct*/if (ignoreAMPMPatterns.has(z) && !/\s(A|AM|P|PM)$/i.test(value)) return null;++ /**+ * Verify by formatting back to string+ * '1000,' => '#,##0,' ----- error+ * '1000,1.00' => '#,##0.00' ----- error+ */+ if (z.includes('#,##0') && numfmt.format(z, v) !== value) return null;}return parseData;diff --git a/packages/sheets-numfmt-ui/src/controllers/__tests__/editor.controller.spec.ts b/packages/sheets-numfmt-ui/src/controllers/__tests__/editor.controller.spec.tsindex b8fa688550..08e9a48150 100644--- a/packages/sheets-numfmt-ui/src/controllers/__tests__/editor.controller.spec.ts+++ b/packages/sheets-numfmt-ui/src/controllers/__tests__/editor.controller.spec.ts@@ -505,6 +505,24 @@ describe('test editor', () => {expect(result?.v).toBe(45691);expect(result?.t).toBe(CellValueType.NUMBER);});++ it('edit content 1000,', () => {+ const sheetInterceptorService = testBed.get(SheetInterceptorService);+ const cellData = { v: '1000,' };+ const location = {+ workbook,+ worksheet,+ unitId,+ subUnitId,+ row: 0,+ col: 0,+ origin: cellData,+ };++ const result = sheetInterceptorService.writeCellInterceptor.fetchThroughInterceptors(AFTER_CELL_EDIT)(cellData, location);++ expect(result?.v).toBe('1000,');+ });});describe('test get cell text/plain', () => {