I'm trying to send in response excel file, but in it I get binary data. If try use reponse data as xlsx file, Excel show that it is corrupted. However if save it locally, everything is fine. For create xlsx file I'm using tealeg/xlsx. What am I doing wrong?
Go:
file := xlsx.NewFile()
...
// filling file with data
...
// works fine
err = file.Save("asd.xlsx")
if err != nil {
fmt.Printf(err.Error())
}
// something went wrong
buffer := new(bytes.Buffer)
if err := file.Write(buffer); err != nil {
return nil, err
}
r := bytes.NewReader(buffer.Bytes())
cr := ioutil.NopCloser(r)
Swagger:
get:
tags:
- "Report"
summary: ""
description: ""
consumes:
- "application/json"
produces:
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
responses:
200:
description: ""
schema:
type: file