From 5d8365ca17240f5b144d437a7b47052f22c4f3c6 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 11 Dec 2019 00:02:33 +0800 Subject: [PATCH] Fix #529, handle empty inline rich text --- rows.go | 5 ++++- rows_test.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/rows.go b/rows.go index 69a9846..ff4aa0f 100644 --- a/rows.go +++ b/rows.go @@ -279,7 +279,10 @@ func (xlsx *xlsxC) getValueFrom(f *File, d *xlsxSST) (string, error) { case "str": return f.formattedValue(xlsx.S, xlsx.V), nil case "inlineStr": - return f.formattedValue(xlsx.S, xlsx.IS.String()), nil + if xlsx.IS != nil { + return f.formattedValue(xlsx.S, xlsx.IS.String()), nil + } + return f.formattedValue(xlsx.S, xlsx.V), nil default: return f.formattedValue(xlsx.S, xlsx.V), nil } diff --git a/rows_test.go b/rows_test.go index 47c9d96..6b50c75 100644 --- a/rows_test.go +++ b/rows_test.go @@ -706,6 +706,15 @@ func TestDuplicateRowInvalidRownum(t *testing.T) { } } +func TestGetValueFrom(t *testing.T) { + c := &xlsxC{T: "inlineStr"} + f := NewFile() + d := &xlsxSST{} + val, err := c.getValueFrom(f, d) + assert.NoError(t, err) + assert.Equal(t, "", val) +} + func TestErrSheetNotExistError(t *testing.T) { err := ErrSheetNotExist{SheetName: "Sheet1"} assert.EqualValues(t, err.Error(), "sheet Sheet1 is not exist")