forked from p30928647/excelize
This commit is contained in:
parent
0c76766c2b
commit
a57203a03a
2
cell.go
2
cell.go
|
@ -1319,7 +1319,7 @@ func (f *File) formattedValue(s int, v string, raw bool) (string, error) {
|
|||
if styleSheet.CellXfs == nil {
|
||||
return v, err
|
||||
}
|
||||
if s >= len(styleSheet.CellXfs.Xf) {
|
||||
if s >= len(styleSheet.CellXfs.Xf) || s < 0 {
|
||||
return v, err
|
||||
}
|
||||
var numFmtID int
|
||||
|
|
|
@ -2,6 +2,7 @@ package excelize
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
_ "image/jpeg"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
|
@ -11,8 +12,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
_ "image/jpeg"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
@ -755,10 +754,16 @@ func TestFormattedValue(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, "43528", result)
|
||||
|
||||
// S is too large
|
||||
result, err = f.formattedValue(15, "43528", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "43528", result)
|
||||
|
||||
// S is too small
|
||||
result, err = f.formattedValue(-15, "43528", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "43528", result)
|
||||
|
||||
result, err = f.formattedValue(1, "43528", false)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "43528", result)
|
||||
|
|
Loading…
Reference in New Issue