This commit is contained in:
parent
e5c5ecc379
commit
a13ef5545e
21
comment.go
21
comment.go
|
@ -43,15 +43,15 @@ func (f *File) GetComments() (comments map[string][]Comment) {
|
||||||
if target == "" {
|
if target == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !filepath.IsAbs(target) {
|
if !strings.HasPrefix(target, "/") {
|
||||||
target = "xl" + strings.TrimPrefix(target, "..")
|
target = "xl" + strings.TrimPrefix(target, "..")
|
||||||
}
|
}
|
||||||
if d := f.commentsReader(strings.TrimPrefix(target, "/")); d != nil {
|
if d := f.commentsReader(strings.TrimPrefix(target, "/")); d != nil {
|
||||||
sheetComments := []Comment{}
|
sheetComments := []Comment{}
|
||||||
for _, comment := range d.CommentList.Comment {
|
for _, comment := range d.CommentList.Comment {
|
||||||
sheetComment := Comment{}
|
sheetComment := Comment{}
|
||||||
if comment.AuthorID < len(d.Authors) {
|
if comment.AuthorID < len(d.Authors.Author) {
|
||||||
sheetComment.Author = d.Authors[comment.AuthorID].Author
|
sheetComment.Author = d.Authors.Author[comment.AuthorID]
|
||||||
}
|
}
|
||||||
sheetComment.Ref = comment.Ref
|
sheetComment.Ref = comment.Ref
|
||||||
sheetComment.AuthorID = comment.AuthorID
|
sheetComment.AuthorID = comment.AuthorID
|
||||||
|
@ -250,20 +250,19 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
|
||||||
t = t[0:32512]
|
t = t[0:32512]
|
||||||
}
|
}
|
||||||
comments := f.commentsReader(commentsXML)
|
comments := f.commentsReader(commentsXML)
|
||||||
|
authorID := 0
|
||||||
if comments == nil {
|
if comments == nil {
|
||||||
comments = &xlsxComments{
|
comments = &xlsxComments{Authors: xlsxAuthor{Author: []string{formatSet.Author}}}
|
||||||
Authors: []xlsxAuthor{
|
}
|
||||||
{
|
if inStrSlice(comments.Authors.Author, formatSet.Author) == -1 {
|
||||||
Author: formatSet.Author,
|
comments.Authors.Author = append(comments.Authors.Author, formatSet.Author)
|
||||||
},
|
authorID = len(comments.Authors.Author) - 1
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
defaultFont := f.GetDefaultFont()
|
defaultFont := f.GetDefaultFont()
|
||||||
bold := ""
|
bold := ""
|
||||||
cmt := xlsxComment{
|
cmt := xlsxComment{
|
||||||
Ref: cell,
|
Ref: cell,
|
||||||
AuthorID: 0,
|
AuthorID: authorID,
|
||||||
Text: xlsxText{
|
Text: xlsxText{
|
||||||
R: []xlsxR{
|
R: []xlsxR{
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,7 +24,7 @@ import "encoding/xml"
|
||||||
// something special about the cell.
|
// something special about the cell.
|
||||||
type xlsxComments struct {
|
type xlsxComments struct {
|
||||||
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main comments"`
|
XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main comments"`
|
||||||
Authors []xlsxAuthor `xml:"authors"`
|
Authors xlsxAuthor `xml:"authors"`
|
||||||
CommentList xlsxCommentList `xml:"commentList"`
|
CommentList xlsxCommentList `xml:"commentList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ type xlsxComments struct {
|
||||||
// have an author. The maximum length of the author string is an implementation
|
// have an author. The maximum length of the author string is an implementation
|
||||||
// detail, but a good guideline is 255 chars.
|
// detail, but a good guideline is 255 chars.
|
||||||
type xlsxAuthor struct {
|
type xlsxAuthor struct {
|
||||||
Author string `xml:"author"`
|
Author []string `xml:"author"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// xlsxCommentList (List of Comments) directly maps the xlsxCommentList element.
|
// xlsxCommentList (List of Comments) directly maps the xlsxCommentList element.
|
||||||
|
|
Loading…
Reference in New Issue