Documentation ¶
Overview ¶
Package xls2csv is a Golang package which converts XLS file to CSV records. It's based on libxls and xls2csv.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func XLS2CSV ¶
XLS2CSV converts XLS file to CSV records.
Params: xlsFile: XLS file name. sheetID: sheet ID to be converted. It's 0-based. Return: records: CSV records. Each record is a slice of fields. See https://godoc.org/encoding/csv#Reader.ReadAll for more info.
Example ¶
Run "go test -c && ./xls2csv.test" to test.
package main import ( "fmt" "log" "github.com/goshlanguage/xls2csv-go/xls2csv" "github.com/northbright/pathhelper" ) func main() { 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 { fmt.Printf("\n") } } end: }
Output: [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]
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.