GoSpread wraps google.golang.org/api/sheets/v4
.
- manage sheets
- create, sort, move
Use go get
to install the library.
go get -u github.com/duhshu/gospread
Install gospraed
command.
go get github.com/duhshu/gospread/cmd/gospread
- Enable sheets api to
https://console.developers.google.com/
. - Create service account, and create key and download to
creadential.json
- Share a sheets for service account email.
gospread sheets create sheet-name <spread-sheet-id>
your application.
import "github.com/duhshu/gospread"
func main() {
g, err := gospread.NewGoSpreadWithCredentialFile("credential.json")
if err != nil {
fmt.Fatal(err)
}
if err := g.CreateSheet("spread-sheet-id", "new-sheet-name"); err != nil {
fmt.Printf("createTestSheet error=%s", err)
}
}