diff options
author | xuri <xuri.me@gmail.com> | 2020-05-17 17:36:53 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-05-17 17:36:53 +0800 |
commit | 98221a332ff9c37c9b20c44e9efdbe4c22a5cf5c (patch) | |
tree | dcdffe469b8ec3d37e2739207f7316e7692341db /picture_test.go | |
parent | 9b7d8463d39ad5fcaae24e5a3b7da296c5e29d17 (diff) |
Merge pull request #410
Diffstat (limited to 'picture_test.go')
-rw-r--r-- | picture_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/picture_test.go b/picture_test.go index fdc6f0d..015d854 100644 --- a/picture_test.go +++ b/picture_test.go @@ -47,6 +47,15 @@ func TestAddPicture(t *testing.T) { file, err := ioutil.ReadFile(filepath.Join("test", "images", "excel.png")) assert.NoError(t, err) + // Test add picture to worksheet with autofit. + assert.NoError(t, f.AddPicture("Sheet1", "A30", filepath.Join("test", "images", "excel.jpg"), `{"autofit": true}`)) + assert.NoError(t, f.AddPicture("Sheet1", "B30", filepath.Join("test", "images", "excel.jpg"), `{"x_offset": 10, "y_offset": 10, "autofit": true}`)) + f.NewSheet("AddPicture") + assert.NoError(t, f.SetRowHeight("AddPicture", 10, 30)) + assert.NoError(t, f.MergeCell("AddPicture", "B3", "D9")) + assert.NoError(t, f.AddPicture("AddPicture", "C6", filepath.Join("test", "images", "excel.jpg"), `{"autofit": true}`)) + assert.NoError(t, f.AddPicture("AddPicture", "A1", filepath.Join("test", "images", "excel.jpg"), `{"autofit": true}`)) + // Test add picture to worksheet from bytes. assert.NoError(t, f.AddPictureFromBytes("Sheet1", "Q1", "", "Excel Logo", ".png", file)) // Test add picture to worksheet from bytes with illegal cell coordinates. @@ -181,3 +190,15 @@ func TestDeletePicture(t *testing.T) { // Test delete picture on no chart worksheet. assert.NoError(t, NewFile().DeletePicture("Sheet1", "A1")) } + +func TestDrawingResize(t *testing.T) { + f := NewFile() + // Test calculate drawing resize on not exists worksheet. + _, _, _, _, err := f.drawingResize("SheetN", "A1", 1, 1, nil) + assert.EqualError(t, err, "sheet SheetN is not exist") + // Test calculate drawing resize with invalid coordinates. + _, _, _, _, err = f.drawingResize("Sheet1", "", 1, 1, nil) + assert.EqualError(t, err, `cannot convert cell "" to coordinates: invalid cell name ""`) + f.Sheet["xl/worksheets/sheet1.xml"].MergeCells = &xlsxMergeCells{Cells: []*xlsxMergeCell{{Ref: "A:A"}}} + assert.EqualError(t, f.AddPicture("Sheet1", "A1", filepath.Join("test", "images", "excel.jpg"), `{"autofit": true}`), `cannot convert cell "A" to coordinates: invalid cell name "A"`) +} |