summaryrefslogtreecommitdiff
path: root/excelize.go
diff options
context:
space:
mode:
Diffstat (limited to 'excelize.go')
-rw-r--r--excelize.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/excelize.go b/excelize.go
index 0c0f74a..3a511d1 100644
--- a/excelize.go
+++ b/excelize.go
@@ -22,6 +22,7 @@ import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"strconv"
"strings"
"sync"
@@ -112,7 +113,7 @@ func OpenReader(r io.Reader, opt ...Options) (*File, error) {
return nil, err
}
f := newFile()
- if bytes.Contains(b, oleIdentifier) {
+ if bytes.Contains(b, oleIdentifier) && len(opt) > 0 {
for _, o := range opt {
f.options = &o
}
@@ -345,7 +346,9 @@ func (f *File) AddVBAProject(bin string) error {
return errors.New("unsupported VBA project extension")
}
f.setContentTypePartVBAProjectExtensions()
- wb := f.relsReader("xl/_rels/workbook.xml.rels")
+ wbPath := f.getWorkbookPath()
+ wbRelsPath := strings.TrimPrefix(filepath.Join(filepath.Dir(wbPath), "_rels", filepath.Base(wbPath)+".rels"), string(filepath.Separator))
+ wb := f.relsReader(wbRelsPath)
var rID int
var ok bool
for _, rel := range wb.Relationships {