summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorSustainedhhh <15829307082_pp@sina.cn>2019-07-25 20:31:21 +0800
committerGitHub <noreply@github.com>2019-07-25 20:31:21 +0800
commit0c9e5137e35b32e6046d25604edcb9a33f8353a2 (patch)
tree7b034f334b12cc1eb7428df5d5feea59967b789b /sheet.go
parentc1357ee58fb7478645fa22adc7a5905e86c1f7c1 (diff)
Fix #442
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/sheet.go b/sheet.go
index 1c19e86..32fc351 100644
--- a/sheet.go
+++ b/sheet.go
@@ -372,7 +372,12 @@ func (f *File) getSheetMap() map[string]string {
for _, v := range content.Sheets.Sheet {
for _, rel := range rels.Relationships {
if rel.ID == v.ID {
- maps[v.Name] = fmt.Sprintf("xl/%s", rel.Target)
+ // Construct a target XML as xl/worksheets/sheet%d by split path, compatible with different types of relative paths in workbook.xml.rels, for example: worksheets/sheet%d.xml and /xl/worksheets/sheet%d.xml
+ pathInfo := strings.Split(rel.Target, "/")
+ pathInfoLen := len(pathInfo)
+ if pathInfoLen > 0 {
+ maps[v.Name] = fmt.Sprintf("xl/worksheets/%s", pathInfo[pathInfoLen-1])
+ }
}
}
}