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
[Question] How can I send the xlxs file as a http response without actually creating the file? #148
Comments
Thanks for your issue. http.ResponseWriter implements
|
@xuri Thanks! I off work today. Will try this asap. Do I still need to xlxs.SaveAs? |
@xuri yeap that did it! There is no need to SaveAs, just Write(w) works. How about? func (f *File) SendThroughHTTP(w http.ResponseWriter, filename string){
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", "attachment; filename="+filename+".xlsx")
w.Header().Set("Content-Transfer-Encoding", "binary")
f.Write(w)
} |
@cescoferraro That would add an unnecessary dependency of |
@cescoferraro : as you mentioned in above comment, we can achieve it without calling saveAs function. I have executed the above code after removing saveAs function. When i did HTTP request it give me Response in Binary format.
How can i save it as file with xlsx extension after making http request? Please let me know if you need more detail. |
When saving the file directly to disk with Now I'm using the github.com/awslabs/aws-lambda-go-api-proxy/handlerfunc library which uses the |
as you mentioned @xuri , use write function return file instream, the xlsx file downloaded , opening it isn't recognized and need to repair. can you tell me the problem? |
Guys any solution for it? |
@cescoferraro, @pulpfree, @zsspj12, @khawerrind The execlize now support to get bytes.Buffer from the saved file by buf, _ := xlsx.WriteToBuffer()
strings.NewReader(buf.String()) Reference issue #127. |
I want to create a GET endpoint where the user downloads the xlxs file created with excelize.
How can I achive such thing without actually creating a FS file. The below works, but its far from ideal.
The text was updated successfully, but these errors were encountered: