已验证 提交 1bc53020 编写于 作者: xurime's avatar xurime

Fixed #764, add a condition for round precision

上级 b260485f
...@@ -124,8 +124,9 @@ func TestSetCellValues(t *testing.T) { ...@@ -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)) err = f.SetCellValue("Sheet1", "A1", time.Date(1600, time.December, 31, 0, 0, 0, 0, time.UTC))
assert.NoError(t, err) assert.NoError(t, err)
_, err = f.GetCellValue("Sheet1", "A1") v, err = f.GetCellValue("Sheet1", "A1")
assert.EqualError(t, err, `strconv.ParseFloat: parsing "1600-12-31T00:00:00Z": invalid syntax`) assert.NoError(t, err)
assert.Equal(t, v, "1600-12-31T00:00:00Z")
} }
func TestSetCellBool(t *testing.T) { func TestSetCellBool(t *testing.T) {
......
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"log" "log"
"math" "math"
"strconv" "strconv"
"strings"
"github.com/mohae/deepcopy" "github.com/mohae/deepcopy"
) )
...@@ -345,7 +346,8 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) { ...@@ -345,7 +346,8 @@ func (c *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) {
} }
return f.formattedValue(c.S, c.V), nil return f.formattedValue(c.S, c.V), nil
default: default:
if len(c.V) > 16 { splited := strings.Split(c.V, ".")
if len(splited) == 2 && len(splited[1]) > 15 {
val, err := roundPrecision(c.V) val, err := roundPrecision(c.V)
if err != nil { if err != nil {
return "", err return "", err
......
...@@ -1137,7 +1137,7 @@ type PageLayoutOptionPtr interface { ...@@ -1137,7 +1137,7 @@ type PageLayoutOptionPtr interface {
type ( type (
// BlackAndWhite specified print black and white. // BlackAndWhite specified print black and white.
BlackAndWhite bool 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. // specified, then 'automatic' is assumed.
FirstPageNumber uint FirstPageNumber uint
// PageLayoutOrientation defines the orientation of page layout for a // PageLayoutOrientation defines the orientation of page layout for a
...@@ -1145,9 +1145,9 @@ type ( ...@@ -1145,9 +1145,9 @@ type (
PageLayoutOrientation string PageLayoutOrientation string
// PageLayoutPaperSize defines the paper size of the worksheet. // PageLayoutPaperSize defines the paper size of the worksheet.
PageLayoutPaperSize int PageLayoutPaperSize int
// FitToHeight specified number of vertical pages to fit on. // FitToHeight specified the number of vertical pages to fit on.
FitToHeight int FitToHeight int
// FitToWidth specified number of horizontal pages to fit on. // FitToWidth specified the number of horizontal pages to fit on.
FitToWidth int FitToWidth int
// PageLayoutScale defines the print scaling. This attribute is restricted // PageLayoutScale defines the print scaling. This attribute is restricted
// to values ranging from 10 (10%) to 400 (400%). This setting is // to values ranging from 10 (10%) to 400 (400%). This setting is
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册