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 /rows.go | |
parent | fcca8a38389c7a7f99639dc142b9b10c827ac7ce (diff) |
Compatibility improvement: parse document core part (workbook) dynamically
Diffstat (limited to 'rows.go')
-rw-r--r-- | rows.go | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -19,7 +19,9 @@ import ( "io" "log" "math" + "path/filepath" "strconv" + "strings" ) // GetRows return all the rows in a sheet by given worksheet name (case @@ -288,7 +290,8 @@ func (f *File) GetRowHeight(sheet string, row int) (float64, error) { // after deserialization of xl/sharedStrings.xml. func (f *File) sharedStringsReader() *xlsxSST { var err error - + wbPath := f.getWorkbookPath() + relPath := strings.TrimPrefix(filepath.Join(filepath.Dir(wbPath), "_rels", filepath.Base(wbPath)+".rels"), string(filepath.Separator)) f.Lock() defer f.Unlock() if f.SharedStrings == nil { @@ -308,14 +311,14 @@ func (f *File) sharedStringsReader() *xlsxSST { } } f.addContentTypePart(0, "sharedStrings") - rels := f.relsReader("xl/_rels/workbook.xml.rels") + rels := f.relsReader(relPath) for _, rel := range rels.Relationships { - if rel.Target == "sharedStrings.xml" { + if rel.Target == "/xl/sharedStrings.xml" { return f.SharedStrings } } - // Update xl/_rels/workbook.xml.rels - f.addRels("xl/_rels/workbook.xml.rels", SourceRelationshipSharedStrings, "sharedStrings.xml", "") + // Update workbook.xml.rels + f.addRels(relPath, SourceRelationshipSharedStrings, "/xl/sharedStrings.xml", "") } return f.SharedStrings |