gospread

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 8 Imported by: 0

README

GoSpread - Google Spreadsheets utility

GoSpread wraps google.golang.org/api/sheets/v4.

Features

  • manage sheets
    • create, sort, move

Installing

Use go get to install the library.

go get -u github.com/daizpan/gospread

Install gospraed command.

go get github.com/daizpan/gospread/cmd/gospread

Usage

  1. Enable sheets api to https://console.developers.google.com/.
  2. Create service account, and create key and download to creadential.json
  3. Share a sheets for service account email.
gospread sheets create sheet-name <spread-sheet-id>

your application.

import "github.com/daizpan/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)
	}
}

Author

daizpan

Licence

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoSpread

type GoSpread struct {
	*sheets.Service
}

func NewGoSpreadWithCredentialFile

func NewGoSpreadWithCredentialFile(credential string) (*GoSpread, error)

NewGoSpreadWithCredentialFile is credential fileを引数にGoSpreadを生成

func NewGoSpreadWithCredentialsJSON

func NewGoSpreadWithCredentialsJSON(ctx context.Context, jsonData []byte) (*GoSpread, error)

func (*GoSpread) AppendRows

func (g *GoSpread) AppendRows(spreadsheetId string, sheetName string, values [][]interface{}) error

func (*GoSpread) BatchUpdate

func (g *GoSpread) BatchUpdate(spreadsheetId string, req *sheets.BatchUpdateSpreadsheetRequest) (*sheets.BatchUpdateSpreadsheetResponse, error)

func (*GoSpread) BatchUpdateValues added in v0.2.0

func (g *GoSpread) BatchUpdateValues(spreadsheetId string, batchupdatevaluesrequest *sheets.BatchUpdateValuesRequest) (*sheets.BatchUpdateValuesResponse, error)

func (*GoSpread) CreateSheet

func (g *GoSpread) CreateSheet(spreadsheetId string, sheetName string) error

func (*GoSpread) DeleteAllSheet

func (g *GoSpread) DeleteAllSheet(spreadsheetId string, exclusionSheet []string) error

func (*GoSpread) DeleteSheet

func (g *GoSpread) DeleteSheet(spreadsheetId string, sheetId int64) error

func (*GoSpread) DeleteSheetByName

func (g *GoSpread) DeleteSheetByName(spreadsheetId string, sheetName string) error

func (*GoSpread) GetSpreadSheet

func (g *GoSpread) GetSpreadSheet(spreadsheetId string) (*sheets.Spreadsheet, error)

func (*GoSpread) GetValues

func (g *GoSpread) GetValues(spreadSheetId string, sheetName string, _range string) (*sheets.ValueRange, error)

GetValues: Get sheet data

func (*GoSpread) MoveSheet

func (g *GoSpread) MoveSheet(sheetId int64, index int64, spreadsheetId string) error

func (*GoSpread) SheetExists

func (g *GoSpread) SheetExists(spreadsheetId string, sheetName string) bool

SheetExists: Check sheet exists.

func (*GoSpread) SheetId

func (g *GoSpread) SheetId(spreadsheetId string, sheetName string) (int64, error)

func (*GoSpread) SortSheets

func (g *GoSpread) SortSheets(spreadsheetId string) error

func (*GoSpread) UpdateValues

func (g *GoSpread) UpdateValues(spreadsheetId string, updateRange string, value *sheets.ValueRange) (*sheets.UpdateValuesResponse, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL