diff options
author | xuri <xuri.me@gmail.com> | 2020-11-04 00:28:20 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-11-04 00:28:20 +0800 |
commit | c82a185af83b8b3934efcb0b227e494a18f426ea (patch) | |
tree | cb87009836fd0b879c4af1516ff9e6daf6faa043 /chart.go | |
parent | fcca8a38389c7a7f99639dc142b9b10c827ac7ce (diff) |
Compatibility improvement: parse document core part (workbook) dynamically
Diffstat (limited to 'chart.go')
-rw-r--r-- | chart.go | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -16,6 +16,7 @@ import ( "encoding/xml" "errors" "fmt" + "path/filepath" "strconv" "strings" ) @@ -800,9 +801,11 @@ func (f *File) AddChartSheet(sheet, format string, combo ...string) error { f.addContentTypePart(chartID, "chart") f.addContentTypePart(sheetID, "chartsheet") f.addContentTypePart(drawingID, "drawings") - // Update xl/_rels/workbook.xml.rels - rID := f.addRels("xl/_rels/workbook.xml.rels", SourceRelationshipChartsheet, fmt.Sprintf("chartsheets/sheet%d.xml", sheetID), "") - // Update xl/workbook.xml + // Update workbook.xml.rels + wbPath := f.getWorkbookPath() + wbRelsPath := strings.TrimPrefix(filepath.Join(filepath.Dir(wbPath), "_rels", filepath.Base(wbPath)+".rels"), string(filepath.Separator)) + rID := f.addRels(wbRelsPath, SourceRelationshipChartsheet, fmt.Sprintf("/xl/chartsheets/sheet%d.xml", sheetID), "") + // Update workbook.xml f.setWorkbook(sheet, sheetID, rID) chartsheet, _ := xml.Marshal(cs) f.addSheetNameSpace(sheet, NameSpaceSpreadSheet) |