io.Reader not io.ReaderAt
This commit is contained in:
parent
d9f4a2f154
commit
e8ba09d0c5
17
excelize.go
17
excelize.go
|
@ -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.
Loading…
Reference in New Issue