You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
1.1 KiB

package project
import (
"fmt"
"github.com/gin-gonic/gin"
"io"
"net/http"
"os"
)
func peopleMsg(c *gin.Context) {
file, err := os.Open("people.xls")
if err != nil {
c.JSON(http.StatusNotFound, gin.H{
"result": "文件加载失败" + fmt.Sprintf("%s", err),
})
fmt.Printf("%s", err)
return
}
defer file.Close()
c.Writer.Header().Add("Content-Type", "application/octet-stream")
_, err = io.Copy(c.Writer, file)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{
"result": "文件加载失败" + fmt.Sprintf("%s", err),
})
fmt.Printf("%s", err)
return
}
}
func projectMsg(c *gin.Context) {
file, err := os.Open("project.xls")
if err != nil {
c.JSON(http.StatusNotFound, gin.H{
"result": "文件加载失败" + fmt.Sprintf("%s", err),
})
fmt.Printf("%s", err)
return
}
defer file.Close()
c.Writer.Header().Add("Content-Type", "application/octet-stream")
_, err = io.Copy(c.Writer, file)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{
"result": "文件加载失败" + fmt.Sprintf("%s", err),
})
fmt.Printf("%s", err)
return
}
}