Quellcode durchsuchen

Fix #386 regression test added (#440)

* #386 regression test added

* closes #386 string to bigint on GOARCH=386
Vsevolod Balashov vor 6 Jahren
Ursprung
Commit
1fc4bc52fb
3 geänderte Dateien mit 14 neuen und 1 gelöschten Zeilen
  1. 13 0
      cell_test.go
  2. 1 1
      styles.go
  3. BIN
      test/OverflowNumericCell.xlsx

+ 13 - 0
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")
+}

+ 1 - 1
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

BIN
test/OverflowNumericCell.xlsx