-
Hi! I'm generating a table and wish that users be able to save it as excel file. But c.Attachment requires a real file and c.Blob does not triggers the browser to save a file. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
First thing that I found: https://stackoverflow.com/a/15703536 basically you need to tell browser which type of attachment ( |
Beta Was this translation helpful? Give feedback.
-
Here is what I'm using (without making an actual file) func GetSampleCsvFile(c echo.Context) error {
c.Response().Header().Set(echo.HeaderContentDisposition, "attachment; filename=times-sample.csv")
return c.Blob(http.StatusOK, "text/csv", someservice.GetSampleCsv())
} |
Beta Was this translation helpful? Give feedback.
First thing that I found: https://stackoverflow.com/a/15703536 basically you need to tell browser which type of attachment (
Content-Type
header) the server is sending and if it knows how to handle (to use which program to open) it - it will will use Excel to open that attachment.