A
A
Andrey Astafiev2016-11-09 17:57:34
go
Andrey Astafiev, 2016-11-09 17:57:34

How to convert file from *.csv to *.xlsx in Golang?

db, err := sql.Open("postgres", fmt.Sprintf("user=%s dbname=%s host=%s sslmode=disable",
    DB_USER, DB_NAME, "/var/run/postgresql"))
  defer db.Close()
  checkErr(err)

  db.Query("Copy (Select * From export) To '/var/www/html/exportGo/export/testt.csv' With CSV DELIMITER ',';")

now the resulting file needs to be converted to xlsx

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2016-11-10
@gentee

You need to go to github and search for xlsx. There are a lot of ready-made golang libraries for working with xlsx.
For example https://github.com/tealeg/xlsx
Or even https://github.com/tealeg/csv2xlsx A simple program to convert CSV files into XLSX files.
In general, xlsx is just a format - in fact, xml is packed in zip - you can do everything from scratch.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question