https://github.com/godzie44/go-xls
Libxls for GO
https://github.com/godzie44/go-xls
go golang xls
Last synced: 6 months ago
JSON representation
Libxls for GO
- Host: GitHub
- URL: https://github.com/godzie44/go-xls
- Owner: godzie44
- License: mit
- Created: 2021-03-30T07:47:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-09T17:48:57.000Z (over 4 years ago)
- Last Synced: 2025-03-27T07:35:50.326Z (7 months ago)
- Topics: go, golang, xls
- Language: Go
- Homepage:
- Size: 12.1 MB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


[](https://coveralls.io/github/godzie44/go-xls?branch=master)# GO-xls
GO wrapper for **[libxls](https://github.com/libxls)**. Read old Excel files (.xls) from GO.## Install
1) install **[libxls](https://github.com/libxls)**
2) add CGO_LDFLAGS=-lxlsreader to go build / go test command.See /example/Dockerfile as example of installing required dependencies.
## Example
```go
import "github.com/godzie44/go-xls/xls"wb, err := xls.OpenFile(someFile, "UTF-8")
if err != nil {
log.Fatal(err)
}
defer wb.Close()sheet, err := wb.OpenWorkSheet(0)
if err != nil {
log.Fatal(err)
}
defer sheet.Close()for _, row := range sheet.Rows {
for _, cell := range row.Cells {
fmt.Println(cell.Value.String())
}
}
```Or more specialized cell parsing:
```go
//...for _, row := range sheet.Rows {
for _, cell := range row.Cells {
switch v := cell.Value.(type) {
case *BlankValue:
fmt.Printf("%T no val \n", v)
case *FloatValue:
fmt.Printf("%T %f \n", v, v.Val)
case *BoolValue:
fmt.Printf("%T %t \n", v, v.Val)
case *ErrValue:
fmt.Printf("%T %d \n", v, v.Code)
case *StringValue:
fmt.Printf("%T %s \n", v, v.Val)
case *UnknownValue:
fmt.Printf("%T %s \n", v, v.Val)
}
}
}
}
```Also, use `make example` command for run example project (converting xls table to html).