xls2csv-go: github.com/northbright/xls2csv-go/xls2csv Index | Examples | Files

package xls2csv

import "github.com/northbright/xls2csv-go/xls2csv"

Package xls2csv is a Golang package which converts XLS file to CSV records. It's based on libxls and xls2csv.



Package Files

doc.go xls2csv.go

func XLS2CSV Uses

func XLS2CSV(xlsFile string, sheetID int) (records [][]string, err error)

XLS2CSV converts XLS file to CSV records.

  xlsFile: XLS file name.
  sheetID: sheet ID to be converted. It's 0-based.
  records: CSV records. Each record is a slice of fields.
           See https://godoc.org/encoding/csv#Reader.ReadAll for more info.

Run "go test -c && ./xls2csv.test" to test.


const xlsFile string = "./files/my.xls"
var err error
records := [][]string{}

// Get absolute path of XLS file.
f, _ := pathhelper.GetAbsPath(xlsFile)

// Call XLS2CSV() to convert XLS and get all records.
if records, err = xls2csv.XLS2CSV(f, 0); err != nil {
    log.Printf("XLS2CSV() error: %v\n", err)
    goto end

for i, row := range records {
    fmt.Printf("%v", row)
    if i != len(records)-1 {



[Product Vendor Price]
[iPhone 7 Plus Gold 128GB Apple 7188]
[iPhone 7 Plus Gold 128GB JD 6399]
[iPhone 7 Plus Gold 128GB YHD 6488]
[iPhone 7 Gold 128GB Apple 6188]
[iPhone 7 Gold 128GB JD 5499]
[iPhone 7 Gold 128GB YHD 5498]

Package xls2csv imports 5 packages (graph) and is imported by 1 packages. Updated 2017-12-22. Refresh now. Tools for package owners.