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): fix the numfmt func change the null to string (#5344)

VicKunc57b4d07de57
diff --git a/packages/sheets-numfmt/src/utils/pattern.ts b/packages/sheets-numfmt/src/utils/pattern.ts
index d33882fe7f..c893c365e1 100644
--- a/packages/sheets-numfmt/src/utils/pattern.ts
+++ b/packages/sheets-numfmt/src/utils/pattern.ts
@@ -27,7 +27,8 @@ interface IPatternPreview {
export const getPatternPreview = (pattern: string, value: number, locale: INumfmtLocalTag = 'en'): IPatternPreview => {
// in the source code of numfmt, the formatColor function will read the the partitions[3]
- const color = String(numfmt.formatColor(pattern, value));
+ const formatColor = numfmt.formatColor(pattern, value);
+ const color = formatColor ? String(formatColor) : undefined;
const result = numfmt.format(pattern, value, { locale, throws: false });
if (value < 0) {
// pay attention, controllers/numfmt.controller.ts