From 1fc4bc52fb8a0160eb624e7a24619d8c0e47e540 Mon Sep 17 00:00:00 2001 From: Vsevolod Balashov Date: Sun, 1 Sep 2019 07:30:14 +0300 Subject: [PATCH] Fix #386 regression test added (#440) * #386 regression test added * closes #386 string to bigint on GOARCH=386 --- cell_test.go | 13 +++++++++++++ styles.go | 2 +- test/OverflowNumericCell.xlsx | Bin 0 -> 11445 bytes 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/OverflowNumericCell.xlsx diff --git a/cell_test.go b/cell_test.go index d4a5b02..09627c2 100644 --- a/cell_test.go +++ b/cell_test.go @@ -2,6 +2,7 @@ package excelize import ( "fmt" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -94,3 +95,15 @@ func BenchmarkSetCellValue(b *testing.B) { } } } + +func TestOverflowNumericCell(t *testing.T) { + f, err := OpenFile(filepath.Join("test", "OverflowNumericCell.xlsx")) + if !assert.NoError(t, err) { + t.FailNow() + } + // source of xlsx file is Russia, don`t touch it, elsewhere bug not reproduced + val, err := f.GetCellValue("Лист1", "A1") + assert.NoError(t, err) + // GOARCH=amd64 - all ok; GOARCH=386 - actual : "-2147483648" + assert.Equal(t, "8595602512225", val, "A1 should be 8595602512225") +} diff --git a/styles.go b/styles.go index 16f8030..4d6071a 100644 --- a/styles.go +++ b/styles.go @@ -852,7 +852,7 @@ func formatToInt(i int, v string) string { if err != nil { return v } - return fmt.Sprintf("%d", int(f)) + return fmt.Sprintf("%d", int64(f)) } // formatToFloat provides a function to convert original string to float diff --git a/test/OverflowNumericCell.xlsx b/test/OverflowNumericCell.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..184488827224fdd784315d8c3de25b7ae31f47be GIT binary patch literal 11445 zcmeHtby!?W67S#=+?@n>3+}<)-6232Tm~n>5?m*Q1PHFdg1bv_4{pI7f(Hoj4!L*t z?q=`%-ur*|%y(?M>(^b?Rdu?%N=*?C9uI^FLI#0APe9N3f<_!+Kp=Po5C|893~MOq zoQ{1;20SgX&mg9E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