diff --git a/common/relationship.go b/common/relationship.go index 3b4691ea7b..bcf18c0e90 100644 --- a/common/relationship.go +++ b/common/relationship.go @@ -33,6 +33,11 @@ func (r Relationship) ID() string { return r.x.IdAttr } +// SetTarget set the target (path) of a relationship. +func (r Relationship) SetTarget(s string) { + r.x.TargetAttr = s +} + // Target returns the target (path) of a relationship. func (r Relationship) Target() string { return r.x.TargetAttr diff --git a/spreadsheet/testdata/simple-1.xlsx b/spreadsheet/testdata/simple-1.xlsx index fcb8f2021c..f640a2c9d5 100644 Binary files a/spreadsheet/testdata/simple-1.xlsx and b/spreadsheet/testdata/simple-1.xlsx differ diff --git a/spreadsheet/workbook.go b/spreadsheet/workbook.go index ba325b9c4d..848eaf7f4e 100644 --- a/spreadsheet/workbook.go +++ b/spreadsheet/workbook.go @@ -170,6 +170,9 @@ func Read(r io.ReaderAt, size int64) (*Workbook, error) { decMap[basePaths[wb.wbRels]+zippkg.RelationsPathFor(r.Target())] = wksRel.X() basePaths[wksRel] = basePath wb.xwsRels = append(wb.xwsRels, wksRel) + // fix the relationship target so it points to where we'll save + // the worksheet + r.SetTarget(fmt.Sprintf("worksheets/sheet%d.xml", len(wb.xws))) case common.StylesType: wb.StyleSheet = NewStyleSheet() decMap[basePaths[wb.wbRels]+r.Target()] = wb.StyleSheet.X()