summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVsevolod Balashov <vsevolod@balashov.name>2019-09-01 07:30:14 +0300
committerxuri <xuri.me@gmail.com>2019-09-01 12:30:14 +0800
commit1fc4bc52fb8a0160eb624e7a24619d8c0e47e540 (patch)
treef8172ed5c1207204f4e606570a9176d15ff46346
parent333c5881c0b83ff596fc9a0d6d5378ff6319bbbb (diff)
Fix #386 regression test added (#440)
* #386 regression test added * closes #386 string to bigint on GOARCH=386
-rw-r--r--cell_test.go13
-rw-r--r--styles.go2
-rw-r--r--test/OverflowNumericCell.xlsxbin0 -> 11445 bytes
3 files changed, 14 insertions, 1 deletions
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 0000000..1844888
--- /dev/null
+++ b/test/OverflowNumericCell.xlsx
Binary files differ