diff --git a/excelize.go b/excelize.go index 3c81db28..46e0a846 100644 --- a/excelize.go +++ b/excelize.go @@ -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 diff --git a/test/Workbook1.xlsx b/test/Workbook1.xlsx index ee521871..f5417e90 100644 Binary files a/test/Workbook1.xlsx and b/test/Workbook1.xlsx differ