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 {
return nil, err
}
b, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
return OpenReader(bytes.NewReader(b), int64(len(b)))
defer file.Close()
return OpenReader(file)
}
// OpenReader take an io.Reader and return a populated XLSX file.
func OpenReader(r io.ReaderAt, size int64) (*File, error) {
zr, err := zip.NewReader(r, size)
func OpenReader(r io.Reader) (*File, error) {
b, err := ioutil.ReadAll(r)
if err != nil {
return nil, err
}
zr, err := zip.NewReader(bytes.NewReader(b), int64(len(b)))
if err != nil {
return nil, err
}
file, sheetCount, err := ReadZipReader(zr)
if err != nil {
return nil, err

Binary file not shown.