Merge pull request #300 from taomin597715379/bugfix_297

resolve #297, fix GetSheetMap() failed
This commit is contained in:
xuri 2018-11-24 21:38:39 +08:00 committed by GitHub
commit 724ed5f9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

5
sheet.go Normal file → Executable file
View File

@ -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
}
}