diff options
author | xuri <xuri.me@gmail.com> | 2020-03-31 00:02:00 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-03-31 00:02:00 +0800 |
commit | 3ce4b91be96589847823b6c1b6c123ba7880310f (patch) | |
tree | 1df0f8183d528cccafa677990b2f7624475837ae /comment_test.go | |
parent | 3f89c6e9799c9c82af1305f080416c53d19e64c1 (diff) |
Resolve #345, fix missing comments by GetComments
Diffstat (limited to 'comment_test.go')
-rw-r--r-- | comment_test.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/comment_test.go b/comment_test.go index 5b83162..955d4e8 100644 --- a/comment_test.go +++ b/comment_test.go @@ -29,10 +29,17 @@ func TestAddComments(t *testing.T) { // Test add comment on not exists worksheet. assert.EqualError(t, f.AddComment("SheetN", "B7", `{"author":"Excelize: ","text":"This is a comment."}`), "sheet SheetN is not exist") - + // Test add comment on with illegal cell coordinates + assert.EqualError(t, f.AddComment("Sheet1", "A", `{"author":"Excelize: ","text":"This is a comment."}`), `cannot convert cell "A" to coordinates: invalid cell name "A"`) if assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddComments.xlsx"))) { assert.Len(t, f.GetComments(), 2) } + + f.Comments["xl/comments2.xml"] = nil + f.XLSX["xl/comments2.xml"] = []byte(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><authors><author>Excelize: </author></authors><commentList><comment ref="B7" authorId="0"><text><t>Excelize: </t></text></comment></commentList></comments>`) + comments := f.GetComments() + assert.EqualValues(t, 2, len(comments["Sheet1"])) + assert.EqualValues(t, 1, len(comments["Sheet2"])) } func TestDecodeVMLDrawingReader(t *testing.T) { |