- A efficient tool implemented by go to convert lists to excel/列表转excel的高效工具
- 一个json文件(./data/lst.json),内容如下:
[
{
"name": "Tom",
"age": 22,
"addr": "A City"
},
{
"name": "Peter",
"age": 42,
"addr": "B City"
},
{
"name": "Gogo",
"age": 18,
"addr": "C City"
}
]
- 要把上述的数据转成excel,并且可以指定列名的顺序。json文件可能非常大,转换后效果如下:
- 帮助说明
❯ ./lst2xlsx_mac -h
Usage of ./lst2xlsx:
-jp string
Path to the JSON file
-ord string
Column order
-s string
Sheet name (default "Sheet1")
-sp string
Path to save the Excel file (default "1730988813.xlsx")
- 转excel
./lst2xlsx_mac -jp ./data/lst.json -sp ./data/data1.xlsx -s sheet2 -ord '["name", "addr", "age"]'
go build -ldflags="-s -w" -o lst2xlsx_mac main.go
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o lst2xlsx_win.exe main.go
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o lst2xlsx_linux main.go