package main
import (
"github.com/Luxurioust/excelize"
"fmt"
"os"
"github.com/gin-gonic/gin/json"
)
func main(){
var aa =[]map[string]string{}
xlsx, err:= excelize.OpenFile("C:\\GO_WorkSpace\\blacklist.xlsx")
if err!= nil {
fmt.Println(err)
os.Exit(1)
}
cell := xlsx.GetCellValue("sheet1","B1")
fmt.Println(cell)
rows := xlsx.GetRows("Sheet1")
for _, row := range rows {
bb := make(map[string]string)
bb["ID"] = row[0]
bb["Company"] =row[1]
aa = append(aa,bb)
}
aa = aa[1:]
b, err:= json.Marshal(aa)
if err!= nil {
fmt.Println("error:", err)
}
f,err:= os.OpenFile("blacklist.cfg",os.O_RDWR|os.O_CREATE|os.O_TRUNC,0666)
if err!= nil {
fmt.Println("error:", err)
}
f.Write(b)
}
读execl 输出 json
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/defending/article/details/81015780
猜你喜欢
转载自blog.csdn.net/defending/article/details/81015780
今日推荐
周排行