Skip to content

Commit 0447cb2

Browse files
authored
This close qax-os#1985, fix incorrect result of cell value after apply general number format (qax-os#1986)
- Update unit tests
1 parent 29366fd commit 0447cb2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

numfmt.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -5136,7 +5136,10 @@ func (nf *numberFormat) positiveHandler() string {
51365136
var fmtNum bool
51375137
for _, token := range nf.section[nf.sectionIdx].Items {
51385138
if token.TType == nfp.TokenTypeGeneral {
5139-
return strconv.FormatFloat(nf.number, 'G', 10, 64)
5139+
if isNum, precision, _ := isNumeric(nf.value); isNum && precision > 11 {
5140+
return strconv.FormatFloat(nf.number, 'G', 10, 64)
5141+
}
5142+
return nf.value
51405143
}
51415144
if inStrSlice(supportedNumberTokenTypes, token.TType, true) != -1 {
51425145
fmtNum = true

numfmt_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ func TestNumFmt(t *testing.T) {
1111
for _, item := range [][]string{
1212
{"123", "general", "123"},
1313
{"-123", ";general", "-123"},
14+
{"12345678901", "General", "12345678901"},
1415
{"43543.5448726851", "General", "43543.54487"},
1516
{"-43543.5448726851", "General", "-43543.54487"},
1617
{"1234567890.12345", "General", "1234567890"},

0 commit comments

Comments
 (0)