Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zip: not a valid zip file #821

Closed
medivh13 opened this issue Apr 13, 2021 · 11 comments
Closed

zip: not a valid zip file #821

medivh13 opened this issue Apr 13, 2021 · 11 comments

Comments

@medivh13
Copy link

medivh13 commented Apr 13, 2021

Here is what I do :

`req.Body = http.MaxBytesReader(w, req.Body, maxUploadSize)
if err := req.ParseMultipartForm(maxUploadSize); err != nil {
	log.Println("file size error: %s", err)
	return nil, err
}

_, fileHeader, err := req.FormFile("file")

if err != nil {
	log.Println("error when get file: %s", err)
	return nil, err
}

fileF, err := os.OpenFile("./"+fileHeader.Filename, os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
	log.Println(err)
}
defer fileF.Close()

xlsx, err := excelize.OpenFile("./" + fileHeader.Filename)
if err != nil {
	log.Println(err)
	return nil, err
}`

The file is .xlsx format, but I got error "zip: not a valid zip file"

What should I do to fix this?
@medivh13
Copy link
Author

I use v1.4.1 and v2.3.2 buat the result is the same error, pls help me..

@xuri
Copy link
Member

xuri commented Apr 13, 2021

This issue duplicate with #207, please provides file attachments if you can.

@medivh13
Copy link
Author

medivh13 commented Apr 13, 2021

@medivh13
Copy link
Author

medivh13 commented Apr 13, 2021

yes indeed this issue is same with #207 but i cant find how can I fix this error.. pls help.. this is so urgently

@xuri
Copy link
Member

xuri commented Apr 13, 2021

Note that this library doesn't support the legacy XLS file format currently, also reference #44.

@medivh13
Copy link
Author

wrong attachament sorry.. this is the attachment file :
contoh-template-onboard-terbaru.xlsx
@xuri

@medivh13
Copy link
Author

the file is .XLSX so wht should I do abt this?

@xuri
Copy link
Member

xuri commented Apr 13, 2021

I have tested with your XLSX attachment and it works well, please reference this doc about the open data stream.

@medivh13
Copy link
Author

Do you mean I have to change the excelize.OpenFile with excelize.OpenReader ?

@xuri
Copy link
Member

xuri commented Apr 13, 2021

Yep.

@medivh13
Copy link
Author

OK thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants