import   "github.com/360EntSecGroup-Skylar/excelize"

func httpexcelDonwnLoad(c *gin.Context) {
f := excelize.NewFile()

f.SetCellStr("Sheet1", "A1", "报名时间")
f.SetCellStr("Sheet1", "B1", "玩法选择")
f.SetCellStr("Sheet1", "C1", "电话号码")
f.SetCellStr("Sheet1", "D1", "姓名")


for i, v := range omrs {
f.SetCellStr(
"Sheet1",
fmt.Sprintf("A%d", i+2),
v.CreatedAt.Format("2006-01-02 15:04:05"),
)

f.SetCellStr(
"Sheet1",
fmt.Sprintf("B%d", i+2),
v.PlayDesc,
)

f.SetCellStr(
"Sheet1",
fmt.Sprintf("C%d", i+2),
v.Phone,
)

f.SetCellStr(
"Sheet1",
fmt.Sprintf("D%d", i+2),
v.Realname,
)
}
c.Writer.Header().Set("Content-Type", "text/plain")
disposition := fmt.Sprintf("attachment; filename=\"%s.xlsx\"", url.QueryEscape("某比赛名单"))
c.Writer.Header().Set("Content-Disposition", disposition)


c.Writer.WriteHeader(200)

_, e :=f.WriteTo(c.Writer)
if e!=nil {
c.JSON(200, gin.H{
"errno": 1,
"errmsg": errorx.Wrap(e).Error(),
})
return
}
}