add OpenWithCloser function

This commit is contained in:
刘铭
2018-03-22 09:25:17 +08:00
parent e220ff4a46
commit d1d6f84447
2 changed files with 15 additions and 6 deletions

10
xls.go
View File

@@ -16,6 +16,16 @@ func Open(file string, charset string) (*WorkBook, error) {
}
}
//Open one xls file and return the closer
func OpenWithCloser(file string, charset string) (*WorkBook, io.Closer, error) {
if fi, err := os.Open(file); err == nil {
wb, err := OpenReader(fi, charset)
return wb, fi, err
} else {
return nil, nil, err
}
}
//Open xls file from reader
func OpenReader(reader io.ReadSeeker, charset string) (wb *WorkBook, err error) {
var ole *ole2.Ole