From 1bc5302007e04b83ed542fee993e9a79aea9e370 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 20 Jan 2021 00:14:21 +0800 Subject: [PATCH] Fixed #764, add a condition for round precision --- cell_test.go | 5 +++-- rows.go | 4 +++- sheet.go | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cell_test.go b/cell_test.go index 2122ecac0e..93e9f4c98b 100644 --- a/cell_test.go +++ b/cell_test.go @@ -124,8 +124,9 @@ func TestSetCellValues(t *testing.T) { err = f.SetCellValue("Sheet1", "A1", time.Date(1600, time.December, 31, 0, 0, 0, 0, time.UTC)) assert.NoError(t, err) - _, err = f.GetCellValue("Sheet1", "A1") - assert.EqualError(t, err, `strconv.ParseFloat: parsing "1600-12-31T00:00:00Z": invalid syntax`) + v, err = f.GetCellValue("Sheet1", "A1") + assert.NoError(t, err) + assert.Equal(t, v, "1600-12-31T00:00:00Z") } func TestSetCellBool(t *testing.T) { diff --git a/rows.go b/rows.go index 1e29d8f8e2..44c4b643a4 100644 --- a/rows.go +++ b/rows.go @@ -20,6 +20,7 @@ import ( "log" "math" "strconv" + "strings" "github.com/mohae/deepcopy" ) @@ -345,7 +346,8 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) { } return f.formattedValue(c.S, c.V), nil default: - if len(c.V) > 16 { + splited := strings.Split(c.V, ".") + if len(splited) == 2 && len(splited[1]) > 15 { val, err := roundPrecision(c.V) if err != nil { return "", err diff --git a/sheet.go b/sheet.go index 4e56943975..9b80395ef8 100644 --- a/sheet.go +++ b/sheet.go @@ -1137,7 +1137,7 @@ type PageLayoutOptionPtr interface { type ( // BlackAndWhite specified print black and white. BlackAndWhite bool - // FirstPageNumber specified first printed page number. If no value is + // FirstPageNumber specified the first printed page number. If no value is // specified, then 'automatic' is assumed. FirstPageNumber uint // PageLayoutOrientation defines the orientation of page layout for a @@ -1145,9 +1145,9 @@ type ( PageLayoutOrientation string // PageLayoutPaperSize defines the paper size of the worksheet. PageLayoutPaperSize int - // FitToHeight specified number of vertical pages to fit on. + // FitToHeight specified the number of vertical pages to fit on. FitToHeight int - // FitToWidth specified number of horizontal pages to fit on. + // FitToWidth specified the number of horizontal pages to fit on. FitToWidth int // PageLayoutScale defines the print scaling. This attribute is restricted // to values ranging from 10 (10%) to 400 (400%). This setting is