This is a creation in Article, where the information may have evolved or changed.
Previously written in an export CVS format, if only simple export can fully meet the needs. On time if you want to have complex needs, such as style customization, multiple sheet and so on, it will not be completed. Later found someone has implemented Golang direct Excel to Excel operations, here to share a bit.
Address: https://github.com/tealeg/xlsx
Specific types of operations can be seen directly inside the sample or directly view the code, the usage is very simple. Here is a simple test example:
Package Mainimport ("FMT" "github.com/tealeg/xlsx") func test1 () {var file *xlsx. Filevar sheet *xlsx. Sheetvar row *xlsx. Rowvar cell *xlsx. Cellvar Err ErrorFile = xlsx. NewFile () sheet = file. Addsheet ("Sheet1") row = sheet. AddRow () cell = row. Addcell () cell. Value = "000101" cell = row. Addcell () cell. Value = "Chinese" err = file. Save ("myxlsxfile.xlsx") if err! = Nil {fmt. Printf (Err. Error ())}}func test2 () {var file *xlsx. Filevar sheet *xlsx. Sheetvar row *xlsx. Rowvar cell *xlsx. Cellvar Err ErrorFile, _ = xlsx. OpenFile ("myxlsxfile.xlsx") sheet = file. sheet["Sheet1"]row = Sheet. AddRow () cell = row. Addcell () cell. Value = "000101" cell = row. Addcell () cell. Value = "Chinese 1" err = file. Save ("myxlsxfile1.xlsx") if err! = Nil {fmt. Printf (Err. Error ())}}func main () {test1 () test2 ()}