diff options
Diffstat (limited to 'pivotTable.go')
-rw-r--r-- | pivotTable.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pivotTable.go b/pivotTable.go index b7c80c2..3a277c3 100644 --- a/pivotTable.go +++ b/pivotTable.go @@ -15,6 +15,7 @@ import ( "encoding/xml" "errors" "fmt" + "path/filepath" "strconv" "strings" ) @@ -138,7 +139,9 @@ func (f *File) AddPivotTable(opt *PivotTableOption) error { } // workbook pivot cache - workBookPivotCacheRID := f.addRels("xl/_rels/workbook.xml.rels", SourceRelationshipPivotCache, fmt.Sprintf("pivotCache/pivotCacheDefinition%d.xml", pivotCacheID), "") + wbPath := f.getWorkbookPath() + wbRelsPath := strings.TrimPrefix(filepath.Join(filepath.Dir(wbPath), "_rels", filepath.Base(wbPath)+".rels"), string(filepath.Separator)) + workBookPivotCacheRID := f.addRels(wbRelsPath, SourceRelationshipPivotCache, fmt.Sprintf("/xl/pivotCache/pivotCacheDefinition%d.xml", pivotCacheID), "") cacheID := f.addWorkbookPivotCache(workBookPivotCacheRID) pivotCacheRels := "xl/pivotTables/_rels/pivotTable" + strconv.Itoa(pivotTableID) + ".xml.rels" @@ -661,7 +664,7 @@ func (f *File) getPivotTableFieldNameDefaultSubtotal(name string, fields []Pivot return false, false } -// addWorkbookPivotCache add the association ID of the pivot cache in xl/workbook.xml. +// addWorkbookPivotCache add the association ID of the pivot cache in workbook.xml. func (f *File) addWorkbookPivotCache(RID int) int { wb := f.workbookReader() if wb.PivotCaches == nil { |