@@ -33,9 +33,7 @@ func parseFormatCommentsSet(formatSet string) (*formatComment, error) {
33
33
func (f * File ) GetComments () (comments map [string ][]Comment ) {
34
34
comments = map [string ][]Comment {}
35
35
for n := range f .sheetMap {
36
- commentID := f .GetSheetIndex (n )
37
- commentsXML := "xl/comments" + strconv .Itoa (commentID ) + ".xml"
38
- c , ok := f .XLSX [commentsXML ]
36
+ c , ok := f .XLSX ["xl" + strings .TrimPrefix (f .getSheetComments (f .GetSheetIndex (n )), ".." )]
39
37
if ok {
40
38
d := xlsxComments {}
41
39
xml .Unmarshal ([]byte (c ), & d )
@@ -58,6 +56,20 @@ func (f *File) GetComments() (comments map[string][]Comment) {
58
56
return
59
57
}
60
58
59
+ // getSheetComments provides the method to get the target comment reference by
60
+ // given worksheet index.
61
+ func (f * File ) getSheetComments (sheetID int ) string {
62
+ var rels = "xl/worksheets/_rels/sheet" + strconv .Itoa (sheetID ) + ".xml.rels"
63
+ var sheetRels xlsxWorkbookRels
64
+ _ = xml .Unmarshal (namespaceStrictToTransitional (f .readXML (rels )), & sheetRels )
65
+ for _ , v := range sheetRels .Relationships {
66
+ if v .Type == SourceRelationshipComments {
67
+ return v .Target
68
+ }
69
+ }
70
+ return ""
71
+ }
72
+
61
73
// AddComment provides the method to add comment in a sheet by given worksheet
62
74
// index, cell and format set (such as author and text). Note that the max
63
75
// author length is 255 and the max text length is 32512. For example, add a
0 commit comments