From 1bb59f75ea71d88a20802f97da7158eb43d082dd Mon Sep 17 00:00:00 2001 From: taomin597715379 <597715379@qq.com> Date: Sat, 24 Nov 2018 21:27:29 +0800 Subject: [PATCH] resolve #297, fix GetSheetMap() failed Change-Id: I585a4a017867b89bd39cb6e711467a46eaa757be --- sheet.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 sheet.go diff --git a/sheet.go b/sheet.go old mode 100644 new mode 100755 index 9861d20..3021946 --- a/sheet.go +++ b/sheet.go @@ -353,8 +353,9 @@ func (f *File) GetSheetMap() map[int]string { sheetMap := map[int]string{} for _, v := range content.Sheets.Sheet { for _, rel := range rels.Relationships { - if rel.ID == v.ID { - rID, _ := strconv.Atoi(strings.TrimSuffix(strings.TrimPrefix(rel.Target, "worksheets/sheet"), ".xml")) + relStr := strings.SplitN(rel.Target, "worksheets/sheet", 2) + if rel.ID == v.ID && len(relStr) == 2 { + rID, _ := strconv.Atoi(strings.TrimSuffix(relStr[1], ".xml")) sheetMap[rID] = v.Name } }