diff options
author | xuri <xuri.me@gmail.com> | 2019-12-23 00:07:40 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2019-12-23 00:07:40 +0800 |
commit | 4e4a5b9b3e052d1694442515492792fb1aa74c5a (patch) | |
tree | ebb0746cc3a26e50ed921f6f25cb295be6c3c417 /excelize.go | |
parent | ae2865d9237cfd27d7bc4fbef3870b3361597be8 (diff) |
Improve compatibility, fix workbook's rels ID calc error
Diffstat (limited to 'excelize.go')
-rw-r--r-- | excelize.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/excelize.go b/excelize.go index a2e20ff..135028c 100644 --- a/excelize.go +++ b/excelize.go @@ -203,11 +203,17 @@ func checkSheet(xlsx *xlsxWorksheet) { // relationship type, target and target mode. func (f *File) addRels(relPath, relType, target, targetMode string) int { rels := f.relsReader(relPath) - rID := 0 if rels == nil { rels = &xlsxRelationships{} } - rID = len(rels.Relationships) + 1 + var rID int + for _, rel := range rels.Relationships { + ID, _ := strconv.Atoi(strings.TrimPrefix(rel.ID, "rId")) + if ID > rID { + rID = ID + } + } + rID++ var ID bytes.Buffer ID.WriteString("rId") ID.WriteString(strconv.Itoa(rID)) |