Compare commits

..

No commits in common. "5c92a1fef72ac7e0261fe0c3faa607df125ff752" and "08a12459e6035c7ec2d74373a06697f7bfb948b8" have entirely different histories.

View File

@ -118,13 +118,7 @@ func ToExcelByType(titleList []string, dataList []interface{}, dataType string,
// ResponseXls content 为上面生成的io.ReadSeeker fileTag 为返回前端的文件名
func ResponseXls(c *gin.Context, content io.ReadSeeker, fileTag string) {
fileName := fmt.Sprintf("%s.%s", fileTag, ExcelPrefix)
// 返回 Excel 文件流给前端
c.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
c.Header("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
c.Header("File-Name", fmt.Sprintf("%s", fileName))
c.Header("Access-Control-Expose-Headers", "File-Name")
//_ = c.Writer(c.Writer)
//c.Writer.Header().Add("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
//c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
c.Writer.Header().Add("Content-Disposition", fmt.Sprintf(`attachment; filename="%s"`, fileName))
c.Writer.Header().Add("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
http.ServeContent(c.Writer, c.Request, fileName, time.Now(), content)
}