This close #1985, fix incorrect result of cell value after apply general number format (#1986)

- Update unit tests
This commit is contained in:
Zhang Zhipeng 2024-09-02 09:19:50 +08:00 committed by GitHub
parent 29366fd126
commit 0447cb22c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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"},