From 0447cb22c8e9a0fff4e76d4a499df65555a2de29 Mon Sep 17 00:00:00 2001 From: Zhang Zhipeng <414326615@qq.com> Date: Mon, 2 Sep 2024 09:19:50 +0800 Subject: [PATCH] This close #1985, fix incorrect result of cell value after apply general number format (#1986) - Update unit tests --- numfmt.go | 5 ++++- numfmt_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/numfmt.go b/numfmt.go index cae88d6..265fe28 100644 --- a/numfmt.go +++ b/numfmt.go @@ -5136,7 +5136,10 @@ func (nf *numberFormat) positiveHandler() string { var fmtNum bool for _, token := range nf.section[nf.sectionIdx].Items { if token.TType == nfp.TokenTypeGeneral { - return strconv.FormatFloat(nf.number, 'G', 10, 64) + if isNum, precision, _ := isNumeric(nf.value); isNum && precision > 11 { + return strconv.FormatFloat(nf.number, 'G', 10, 64) + } + return nf.value } if inStrSlice(supportedNumberTokenTypes, token.TType, true) != -1 { fmtNum = true diff --git a/numfmt_test.go b/numfmt_test.go index 61bf41b..c3e1a99 100644 --- a/numfmt_test.go +++ b/numfmt_test.go @@ -11,6 +11,7 @@ func TestNumFmt(t *testing.T) { for _, item := range [][]string{ {"123", "general", "123"}, {"-123", ";general", "-123"}, + {"12345678901", "General", "12345678901"}, {"43543.5448726851", "General", "43543.54487"}, {"-43543.5448726851", "General", "-43543.54487"}, {"1234567890.12345", "General", "1234567890"},