Skip to content

Commit

Permalink
This close #1985, fix incorrect result of cell value after apply gene…
Browse files Browse the repository at this point in the history
…ral number format (#1986)

- Update unit tests
  • Loading branch information
peng committed Sep 2, 2024
1 parent 29366fd commit 0447cb2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion numfmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions numfmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 0447cb2

Please sign in to comment.