在vps上使用go代码时,为什么返回的文件损坏?

here is my code, which creates a new xlsx file using the excelize package and returns it as a bytestream. on localhost everything works properly, but when I deploy it to a vps, the file is corrupted.

func exportdata(rw http.ResponseWriter, request *http.Request) {

    xlsx := excelize.NewFile()

    xlsx.SetCellValue("Sheet1", "A1", "a")

    var b bytes.Buffer
    writr := bufio.NewWriter(&b)
    xlsx.Write(writr)
    writr.Flush()

    fileContents := b.Bytes()
    fileSize := strconv.Itoa(len(fileContents))

    rw.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
    rw.Header().Set("Content-disposition", "attachment;filename=export.xlsx")
    rw.Header().Set("Content-Length", fileSize)
    rw.Write(b.Bytes())
    // t := bytes.NewReader(b.Bytes())
    // http.ServeContent(rw, request, "export.xlsx", time.Now(), t)
}

func main() {

    http.HandleFunc("/", exportdata)
    http.ListenAndServe(":8080", nil)

}