summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2019-05-17 22:58:12 +0800
committerxuri <xuri.me@gmail.com>2019-05-17 22:58:12 +0800
commitf91f548614a7182ce66d55d10ed311e9b7e08a2a (patch)
treea50c4397c12f10d57967f49ffa373d9e5f6f4a27 /sheet.go
parent7e77e14814658486267e3f237f484fa8e63a0cd4 (diff)
Resolve #404, get sheet map by target rels.
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/sheet.go b/sheet.go
index b22592d..e873118 100644
--- a/sheet.go
+++ b/sheet.go
@@ -369,12 +369,18 @@ func (f *File) GetSheetMap() map[int]string {
return sheetMap
}
-// getSheetMap provides a function to get worksheet name and XML file path map of
-// XLSX.
+// getSheetMap provides a function to get worksheet name and XML file path map
+// of XLSX.
func (f *File) getSheetMap() map[string]string {
- maps := make(map[string]string)
- for idx, name := range f.GetSheetMap() {
- maps[name] = "xl/worksheets/sheet" + strconv.Itoa(idx) + ".xml"
+ content := f.workbookReader()
+ rels := f.workbookRelsReader()
+ maps := 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)
+ }
+ }
}
return maps
}