Skip to content

Commit

Permalink
spreadsheet: fix issue loading spreadsheets with non-standard naming
Browse files Browse the repository at this point in the history
  • Loading branch information
tbaliance committed Sep 2, 2017
1 parent 1382069 commit ef0d194
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions common/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified spreadsheet/testdata/simple-1.xlsx
Binary file not shown.
3 changes: 3 additions & 0 deletions spreadsheet/workbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ef0d194

Please sign in to comment.