Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kataras/sheets
:bar_chart: (Unofficial) A Lightweight Google Spreadsheets Client written in Go
https://github.com/kataras/sheets
Last synced: 3 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 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-27T21:34:02.000Z (about 1 year ago)
- Last Synced: 2024-08-01T13:30:13.580Z (5 months ago)
- Language: Go
- Homepage:
- Size: 45.9 KB
- Stars: 12
- Watchers: 5
- 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
[![build status](https://img.shields.io/github/actions/workflow/status/kataras/sheets/ci.yml?style=for-the-badge)](https://github.com/kataras/sheets/actions) [![report card](https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=for-the-badge)](https://goreportcard.com/report/github.com/kataras/sheets) [![godocs](https://img.shields.io/badge/go-%20docs-488AC7.svg?style=for-the-badge)](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 mainimport (
"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).