Skip to content

Commit

Permalink
Fixed qax-os#764, add a condition for round precision
Browse files Browse the repository at this point in the history
  • Loading branch information
xuri committed Jan 19, 2021
1 parent bfaece3 commit 60a01c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions cell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"log"
"math"
"strconv"
"strings"

"github.com/mohae/deepcopy"
)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,17 +1137,17 @@ 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
// worksheet.
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
Expand Down

0 comments on commit 60a01c7

Please sign in to comment.