io.Reader not io.ReaderAt

This commit is contained in:
Josh Fyne 2017-02-16 13:30:05 -05:00
parent d9f4a2f154
commit e8ba09d0c5
2 changed files with 10 additions and 7 deletions

View File

@ -26,19 +26,22 @@ func OpenFile(filename string) (*File, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
b, err := ioutil.ReadAll(file) defer file.Close()
if err != nil { return OpenReader(file)
return nil, err
}
return OpenReader(bytes.NewReader(b), int64(len(b)))
} }
// OpenReader take an io.Reader and return a populated XLSX file. // OpenReader take an io.Reader and return a populated XLSX file.
func OpenReader(r io.ReaderAt, size int64) (*File, error) { func OpenReader(r io.Reader) (*File, error) {
zr, err := zip.NewReader(r, size) b, err := ioutil.ReadAll(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }
zr, err := zip.NewReader(bytes.NewReader(b), int64(len(b)))
if err != nil {
return nil, err
}
file, sheetCount, err := ReadZipReader(zr) file, sheetCount, err := ReadZipReader(zr)
if err != nil { if err != nil {
return nil, err return nil, err

Binary file not shown.