diff options
author | charles.deng <cilendeng@gmail.com> | 2022-10-10 00:11:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-10 00:11:18 +0800 |
commit | 2f5704b114d033e81725f18459f9293a9adfee1e (patch) | |
tree | 0390794673f81669ce8a5d20571c2035c4691586 /stream_test.go | |
parent | b1e776ee33ec78b7f6c2a0de8109009963dea521 (diff) |
Stream writer support to set inline rich text cell (#1121)
Co-authored-by: zhengchao.deng <zhengchao.deng@meican.com>
Diffstat (limited to 'stream_test.go')
-rw-r--r-- | stream_test.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/stream_test.go b/stream_test.go index 80875c7..3c2cc69 100644 --- a/stream_test.go +++ b/stream_test.go @@ -52,11 +52,14 @@ func TestStreamWriter(t *testing.T) { row[0] = []byte("Word") assert.NoError(t, streamWriter.SetRow("A3", row)) - // Test set cell with style. + // Test set cell with style and rich text. styleID, err := file.NewStyle(&Style{Font: &Font{Color: "#777777"}}) assert.NoError(t, err) assert.NoError(t, streamWriter.SetRow("A4", []interface{}{Cell{StyleID: styleID}, Cell{Formula: "SUM(A10,B10)"}}, RowOpts{Height: 45, StyleID: styleID})) - assert.NoError(t, streamWriter.SetRow("A5", []interface{}{&Cell{StyleID: styleID, Value: "cell"}, &Cell{Formula: "SUM(A10,B10)"}})) + assert.NoError(t, streamWriter.SetRow("A5", []interface{}{&Cell{StyleID: styleID, Value: "cell"}, &Cell{Formula: "SUM(A10,B10)"}, []RichTextRun{ + {Text: "Rich ", Font: &Font{Color: "2354e8"}}, + {Text: "Text", Font: &Font{Color: "e83723"}}, + }})) assert.NoError(t, streamWriter.SetRow("A6", []interface{}{time.Now()})) assert.NoError(t, streamWriter.SetRow("A7", nil, RowOpts{Height: 20, Hidden: true, StyleID: styleID})) assert.EqualError(t, streamWriter.SetRow("A7", nil, RowOpts{Height: MaxRowHeight + 1}), ErrMaxRowHeight.Error()) @@ -128,7 +131,7 @@ func TestStreamWriter(t *testing.T) { cells += len(row) } assert.NoError(t, rows.Close()) - assert.Equal(t, 2559558, cells) + assert.Equal(t, 2559559, cells) // Save spreadsheet with password. assert.NoError(t, file.SaveAs(filepath.Join("test", "EncryptionTestStreamWriter.xlsx"), Options{Password: "password"})) assert.NoError(t, file.Close()) |