I have written an article about how to export the CVS format. If it is just a simple export, it can fully meet the needs. If you want to have complex requirements on time, such as style customization and multiple sheets, you cannot do it. Later, we found that some people have implemented the direct Excel operations. Here we will share with you.
Address: https://github.com/tealeg/xlsx
For specific operations, you can directly look at the examples provided here or directly view the code. The usage is still 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 ()}
Goalng export Excel (Excel Format)