summaryrefslogtreecommitdiff
path: root/sheet.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-02-27 00:03:46 +0800
committerxuri <xuri.me@gmail.com>2021-02-27 08:49:10 +0800
commitafe2ebc26143330a15b4396b9be6ca04797a5e8e (patch)
tree3444cab434de14a0cc8d8a9c1d62c35179ffcc54 /sheet.go
parent5a0d885315521a4e703f9de401e2dda834285d5f (diff)
This improves compatibility for absolute XML path, Windows-style directory separator and inline namespace;
Diffstat (limited to 'sheet.go')
-rw-r--r--sheet.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/sheet.go b/sheet.go
index d4362b1..0873644 100644
--- a/sheet.go
+++ b/sheet.go
@@ -157,6 +157,9 @@ func (f *File) workSheetWriter() {
for k, v := range sheet.SheetData.Row {
f.Sheet[p].SheetData.Row[k].C = trimCell(v.C)
}
+ if sheet.SheetPr != nil || sheet.Drawing != nil || sheet.Hyperlinks != nil || sheet.Picture != nil || sheet.TableParts != nil {
+ f.addNameSpaces(p, SourceRelationship)
+ }
// reusing buffer
_ = encoder.Encode(sheet)
f.saveFileList(p, replaceRelationshipsBytes(f.replaceNameSpaceBytes(p, buffer.Bytes())))
@@ -455,7 +458,11 @@ func (f *File) getSheetMap() map[string]string {
// path, compatible with different types of relative paths in
// workbook.xml.rels, for example: worksheets/sheet%d.xml
// and /xl/worksheets/sheet%d.xml
- path := filepath.ToSlash(strings.TrimPrefix(filepath.Clean(fmt.Sprintf("%s/%s", filepath.Dir(f.getWorkbookPath()), rel.Target)), "/"))
+ path := filepath.ToSlash(strings.TrimPrefix(
+ strings.Replace(filepath.Clean(fmt.Sprintf("%s/%s", filepath.Dir(f.getWorkbookPath()), rel.Target)), "\\", "/", -1), "/"))
+ if strings.HasPrefix(rel.Target, "/") {
+ path = filepath.ToSlash(strings.TrimPrefix(strings.Replace(filepath.Clean(rel.Target), "\\", "/", -1), "/"))
+ }
if _, ok := f.XLSX[path]; ok {
maps[v.Name] = path
}