diff options
author | xuri <xuri.me@gmail.com> | 2018-09-14 00:24:49 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2018-09-14 00:24:49 +0800 |
commit | 6ced438f39030e8a9a521548d4112dd002dc2ebe (patch) | |
tree | ef5f2d12a849d68085a7286a2b983f3ad4369d11 /comment.go | |
parent | 4f47737d64fc9d9108675cbc1e73ae93c2d723a9 (diff) |
New function `AddPictureFromBytes()` has been added, this resolve #259 and close #271.
Diffstat (limited to 'comment.go')
-rw-r--r-- | comment.go | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -29,8 +29,8 @@ func parseFormatCommentsSet(formatSet string) (*formatComment, error) { // GetComments retrieves all comments and returns a map of worksheet name to // the worksheet comments. -func (f *File) GetComments() (comments map[string]*xlsxComments) { - comments = map[string]*xlsxComments{} +func (f *File) GetComments() (comments map[string][]Comment) { + comments = map[string][]Comment{} for n := range f.sheetMap { commentID := f.GetSheetIndex(n) commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml" @@ -38,7 +38,20 @@ func (f *File) GetComments() (comments map[string]*xlsxComments) { if ok { d := xlsxComments{} xml.Unmarshal([]byte(c), &d) - comments[n] = &d + sheetComments := []Comment{} + for _, comment := range d.CommentList.Comment { + sheetComment := Comment{} + if comment.AuthorID < len(d.Authors) { + sheetComment.Author = d.Authors[comment.AuthorID].Author + } + sheetComment.Ref = comment.Ref + sheetComment.AuthorID = comment.AuthorID + for _, text := range comment.Text.R { + sheetComment.Text += text.T + } + sheetComments = append(sheetComments, sheetComment) + } + comments[n] = sheetComments } } return |