https://github.com/kataras/sheets
:bar_chart: (Unofficial) A Lightweight Google Spreadsheets Client written in Go
https://github.com/kataras/sheets
Last synced: 9 months ago
JSON representation
:bar_chart: (Unofficial) A Lightweight Google Spreadsheets Client written in Go
- Host: GitHub
- URL: https://github.com/kataras/sheets
- Owner: kataras
- License: mit
- Created: 2020-03-14T23:03:50.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-28T18:45:53.000Z (over 1 year ago)
- Last Synced: 2025-03-25T01:51:10.546Z (10 months ago)
- Language: Go
- Homepage:
- Size: 46.9 KB
- Stars: 13
- Watchers: 4
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ccamel - kataras/sheets - :bar_chart: (Unofficial) A Lightweight Google Spreadsheets Client written in Go (Go)
README
# Sheets
[](https://github.com/kataras/sheets/actions) [](https://goreportcard.com/report/github.com/kataras/sheets) [](https://pkg.go.dev/github.com/kataras/sheets)
Lightweight [Google Spreadsheets](https://docs.google.com/spreadsheets) Client written in Go.
This package is under active development and a **work-in-progress** project. You should NOT use it on production. Please consider using the official [Google's Sheets client for Go](https://developers.google.com/sheets/api/quickstart/go) instead.
## Installation
The only requirement is the [Go Programming Language](https://go.dev/dl).
```sh
$ go get github.com/kataras/sheets@latest
```
## Getting Started
First of all, navigate to and enable the Sheets API Service in your [Google Console](https://console.cloud.google.com/). Place the secret client service account or token file as `client_secret.json` near the executable example.
Example Code:
```go
package main
import (
"context"
"time"
"github.com/kataras/sheets"
)
func main() {
ctx := context.TODO()
// or .Token(ctx, ...)
client := sheets.NewClient(sheets.ServiceAccount(ctx, "client_secret.json"))
var (
spreadsheetID := "1Ku0YXrcy8Nqmji7ABS8AmLAyxP5duQIRwmaAJAqyMYY"
dataRange := "NamedRange or selectors like A1:E4 or *"
records []struct{
Timestamp time.Time
Email string
Username string
IgnoredMe string `sheets:"-"`
}{}
)
// Fill the "records" slice from a spreadsheet of one or more data range.
err := client.ReadSpreadsheet(ctx, &records, spreadsheetID, dataRange)
if err != nil {
panic(err)
}
// Update a spreadsheet on specific range.
updated, err := client.UpdateSpreadsheet(ctx, spreadsheetID, sheets.ValueRange{
Range: "A2:Z",
MajorDimension: sheets.Rows,
Values: [][]interface{}{
{"updated record value: 1.1", "updated record value: 1.2"},
{"updated record value: 2.1", "updated record value: 2.2"},
},
})
// Clears record values of a spreadsheet.
cleared, err := client.ClearSpreadsheet(ctx, spreadsheetID, "A1:E5")
// [...]
}
```
## License
This software is licensed under the [MIT License](LICENSE).