diff options
author | xuri <xuri.me@gmail.com> | 2021-07-07 00:57:43 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-07-07 00:57:43 +0800 |
commit | 90d200a10ba4d8c2ae2eff47ad8e1cca0ab28e76 (patch) | |
tree | 7579365b99b61562404ced4d71058b917b92f003 /cell_test.go | |
parent | b7fece51736977e7d84aca30ecce7f6b3a1251f2 (diff) |
Make the functions `SetSheetRow`, `New Style` and `SetCellStyle` concurrency safety
Diffstat (limited to 'cell_test.go')
-rw-r--r-- | cell_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cell_test.go b/cell_test.go index 91f4804..f11c708 100644 --- a/cell_test.go +++ b/cell_test.go @@ -25,8 +25,20 @@ func TestConcurrency(t *testing.T) { // Concurrency set cell value assert.NoError(t, f.SetCellValue("Sheet1", fmt.Sprintf("A%d", val), val)) assert.NoError(t, f.SetCellValue("Sheet1", fmt.Sprintf("B%d", val), strconv.Itoa(val))) + // Concurrency get cell value _, err := f.GetCellValue("Sheet1", fmt.Sprintf("A%d", val)) assert.NoError(t, err) + // Concurrency set rows + assert.NoError(t, f.SetSheetRow("Sheet1", "B6", &[]interface{}{" Hello", + []byte("World"), 42, int8(1<<8/2 - 1), int16(1<<16/2 - 1), int32(1<<32/2 - 1), + int64(1<<32/2 - 1), float32(42.65418), float64(-42.65418), float32(42), float64(42), + uint(1<<32 - 1), uint8(1<<8 - 1), uint16(1<<16 - 1), uint32(1<<32 - 1), + uint64(1<<32 - 1), true, complex64(5 + 10i)})) + // Concurrency create style + style, err := f.NewStyle(`{"font":{"color":"#1265BE","underline":"single"}}`) + assert.NoError(t, err) + // Concurrency set cell style + assert.NoError(t, f.SetCellStyle("Sheet1", "A3", "A3", style)) // Concurrency add picture assert.NoError(t, f.AddPicture("Sheet1", "F21", filepath.Join("test", "images", "excel.jpg"), `{"x_offset": 10, "y_offset": 10, "hyperlink": "https://github.com/360EntSecGroup-Skylar/excelize", "hyperlink_type": "External", "positioning": "oneCell"}`)) @@ -59,6 +71,7 @@ func TestConcurrency(t *testing.T) { t.Error(err) } assert.Equal(t, "1", val) + assert.NoError(t, f.SaveAs(filepath.Join("test", "TestConcurrency.xlsx"))) } func TestCheckCellInArea(t *testing.T) { |