beego API客户端浏览器下载服务器端的生成excel

// @Title          社区报表导出:必须有数据才能导出
// @Description    导出当天所有案件数量
// @Success 200
// @router /formareadown [get]
func (u *FormController) FormareaDown() {
	u.Ctx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", u.Ctx.Request.Header.Get("Origin"))

	state, path := models_pc.FormareaDown()  //生成excel文件
	//beego.Info("adddddddd", state)
	if "ok" == state {
		u.Ctx.Output.Download(path)
		os.Remove(path)
	}else{
		u.Data["json"] = "file does not exist"
	}
	u.ServeJSON()
}

在这里插入图片描述在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zhizhengguan/article/details/84998595