summaryrefslogtreecommitdiff
path: root/comment.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2019-09-16 01:17:35 +0800
committerxuri <xuri.me@gmail.com>2019-09-16 01:17:35 +0800
commit8922f659788187afa6d0a5d3248e999c2c1bb846 (patch)
tree29b2aae2028eaedc448daef08a5670d6f3ca4604 /comment.go
parenta3ee098ab60d9528a0d6b7a7c475ea8ff7ebaba5 (diff)
Combine functions:
workBookRelsWriter, drawingRelsWriter into relsWriter; drawingRelsReader, workbookRelsReader, workSheetRelsReader into relsReader; addDrawingRelationships, addSheetRelationships into addRels
Diffstat (limited to 'comment.go')
-rw-r--r--comment.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/comment.go b/comment.go
index 97e0e9b..7f3b10d 100644
--- a/comment.go
+++ b/comment.go
@@ -60,7 +60,7 @@ func (f *File) GetComments() (comments map[string][]Comment) {
// given worksheet index.
func (f *File) getSheetComments(sheetID int) string {
var rels = "xl/worksheets/_rels/sheet" + strconv.Itoa(sheetID) + ".xml.rels"
- if sheetRels := f.workSheetRelsReader(rels); sheetRels != nil {
+ if sheetRels := f.relsReader(rels); sheetRels != nil {
for _, v := range sheetRels.Relationships {
if v.Type == SourceRelationshipComments {
return v.Target
@@ -98,8 +98,10 @@ func (f *File) AddComment(sheet, cell, format string) error {
drawingVML = strings.Replace(sheetRelationshipsDrawingVML, "..", "xl", -1)
} else {
// Add first comment for given sheet.
- rID := f.addSheetRelationships(sheet, SourceRelationshipDrawingVML, sheetRelationshipsDrawingVML, "")
- f.addSheetRelationships(sheet, SourceRelationshipComments, sheetRelationshipsComments, "")
+ sheetPath, _ := f.sheetMap[trimSheetName(sheet)]
+ sheetRels := "xl/worksheets/_rels/" + strings.TrimPrefix(sheetPath, "xl/worksheets/") + ".rels"
+ rID := f.addRels(sheetRels, SourceRelationshipDrawingVML, sheetRelationshipsDrawingVML, "")
+ f.addRels(sheetRels, SourceRelationshipComments, sheetRelationshipsComments, "")
f.addSheetLegacyDrawing(sheet, rID)
}
commentsXML := "xl/comments" + strconv.Itoa(commentID) + ".xml"