From f91f548614a7182ce66d55d10ed311e9b7e08a2a Mon Sep 17 00:00:00 2001 From: xuri Date: Fri, 17 May 2019 22:58:12 +0800 Subject: Resolve #404, get sheet map by target rels. --- sheet.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'sheet.go') 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 } -- cgit v1.2.1