gdrive_utils

package module
Version: v0.0.0-...-9a849ce Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

gdrive-utils

Google Drive API Utils

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultClient

func DefaultClient(dir string) (*http.Client, error)

func NewClient

func NewClient(dir string, config *oauth2.Config) *http.Client

Retrieves a token, saves the token, then returns the generated client.

Types

type Filter

type Filter struct {
	Header string
	By     func(v []interface{}) (int, error)
}

type SheetReader

type SheetReader struct {
	ValueRenderOption    string
	DateTimeRenderOption string
	// contains filtered or unexported fields
}

func NewColumnReader

func NewColumnReader(srv *sheets.Service, spreadsheetId, sheetName, header string) (*SheetReader, error)

func NewLastRowReader

func NewLastRowReader(srv *sheets.Service, spreadsheetId, sheetName string) (*SheetReader, error)

func NewReader

func NewReader(srv *sheets.Service, spreadsheetId, sheetName string, rowStart int) (*SheetReader, error)

func NewRowReader

func NewRowReader(srv *sheets.Service, spreadsheetId, sheetName string, filter *Filter) (*SheetReader, error)

func (*SheetReader) Read

func (r *SheetReader) Read() (record []string, err error)

Read reads one record (a slice of fields) from r. If the record has an unexpected number of fields, Read returns the record along with the error ErrFieldCount. Except for that case, Read always returns either a non-nil record or a non-nil error, but not both. If there is no data left to be read, Read returns nil, io.EOF. If ReuseRecord is true, the returned slice may be shared between multiple calls to Read.

func (*SheetReader) ReadAll

func (r *SheetReader) ReadAll() (records [][]string, err error)

ReadAll reads all the remaining records from r. Each record is a slice of fields. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.

type SheetWriter

type SheetWriter struct {
	ValueRenderOption    string
	DateTimeRenderOption string
	// contains filtered or unexported fields
}

func NewRowWriter

func NewRowWriter(srv *sheets.Service, spreadsheetId, sheetName string, filter *Filter) *SheetWriter

func NewWriter

func NewWriter(srv *sheets.Service, spreadsheetId, sheetName string) *SheetWriter

func (*SheetWriter) Error

func (w *SheetWriter) Error() error

func (*SheetWriter) Flush

func (w *SheetWriter) Flush()

func (*SheetWriter) Write

func (w *SheetWriter) Write(row []string) error

type Spreadsheet

type Spreadsheet struct {
	SpreadSheetId string
	// contains filtered or unexported fields
}

func NewSpreadsheet

func NewSpreadsheet(spreadsheetId string, opts ...option.ClientOption) (*Spreadsheet, error)

func (*Spreadsheet) AppendRowData

func (si *Spreadsheet) AppendRowData(sheetId int64, data []string, formatCell bool) error

ref: https://developers.google.com/sheets/api/guides/batchupdate

func (*Spreadsheet) EnsureSheet

func (si *Spreadsheet) EnsureSheet(name string, headers []string) (int64, error)

func (*Spreadsheet) FindEmptyCell

func (si *Spreadsheet) FindEmptyCell(sheetName string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL