From 49257c5918f3aa9f2730021a7e6a24b4835646fd Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 9 Jul 2020 01:24:11 +0800 Subject: support case-sensitive doc parts to improve compatibility --- excelize.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'excelize.go') diff --git a/excelize.go b/excelize.go index 970759c..bac569a 100644 --- a/excelize.go +++ b/excelize.go @@ -220,16 +220,25 @@ func checkSheet(xlsx *xlsxWorksheet) { // addRels provides a function to add relationships by given XML path, // relationship type, target and target mode. func (f *File) addRels(relPath, relType, target, targetMode string) int { + var uniqPart = map[string]string{ + SourceRelationshipSharedStrings: "/xl/sharedStrings.xml", + } rels := f.relsReader(relPath) if rels == nil { rels = &xlsxRelationships{} } var rID int - for _, rel := range rels.Relationships { + for idx, rel := range rels.Relationships { ID, _ := strconv.Atoi(strings.TrimPrefix(rel.ID, "rId")) if ID > rID { rID = ID } + if relType == rel.Type { + if partName, ok := uniqPart[rel.Type]; ok { + rels.Relationships[idx].Target = partName + return rID + } + } } rID++ var ID bytes.Buffer -- cgit v1.2.1