Skip to content

A efficient tool implemented by go to convert lists to excel/列表转excel的高效工具

License

Notifications You must be signed in to change notification settings

JimouChen/go-lst2xlsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-lst2xlsx

  • A efficient tool implemented by go to convert lists to excel/列表转excel的高效工具
image

使用场景

  • 一个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文件可能非常大,转换后效果如下:
image

使用例子

开箱即用(MacOS环境)

  • 帮助说明
❯ ./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"]'

自行编译后使用

本地环境MacOS

go build -ldflags="-s -w" -o lst2xlsx_mac main.go

Windows

GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o lst2xlsx_win.exe main.go

Linux

GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o lst2xlsx_linux main.go

About

A efficient tool implemented by go to convert lists to excel/列表转excel的高效工具

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published