package handler

import (
	"github.com/360EntSecGroup-Skylar/excelize"
	"github.com/gin-gonic/gin"
)

func DownloadExcel(c *gin.Context){
	xlsx := excelize.NewFile()
	xlsx.SetCellValue("Sheet1", "A2", "asdas")
	//_ = xlsx.SaveAs("./aaa.xlsx")
	c.Header("Content-Type", "application/octet-stream")
	c.Header("Content-Disposition", "attachment; filename="+"Workbook.xlsx")
	c.Header("Content-Transfer-Encoding", "binary")
	_ = xlsx.Write(c.Writer)
}

  golang gin框架 get 请求下载随时生成的文件 eg:excel

相关文章:

  • 2021-11-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2021-10-09
  • 2021-04-09
  • 2021-07-25
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-13
  • 2022-12-23
相关资源
相似解决方案