docs

package module
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 20 Imported by: 0

README

Docs SDK

提供便捷的 Lark 云文档操作能力

使用说明

Documentation

Overview

docs 库封装了飞书开放平台的接口,提供便捷的飞书云文档操作能力。

Example (CreateSheet)
spreadSheets := NewClient("", "").RootFolder().CreateSpreadSheet("sheet title")
spreadSheets.Share(PermEdit, false, NewMemberWithEmail("aa.com"))
err := spreadSheets.SheetIndex(1).WriteRows(
	[][]interface{}{
		{"name", "age"},
		{"Ace", 10},
		{"Bob", 11},
	},
).Err
if err != nil {
	fmt.Println("err: ", err.Error())
}
Output:

Example (NewClient)
client := NewClient("", "")
folder := client.RootFolder()
fmt.Println("root folder: ", folder.GetToken())
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCellName

func NewCellName(name string) *cellName

func SetLogLevel

func SetLogLevel(level logrus.Level)

func SheetCellTypeDocument

func SheetCellTypeDocument(docType FileType, docToken string) interface{}

func SheetCellTypeDropdown

func SheetCellTypeDropdown(text []interface{}) interface{}

func SheetCellTypeFormula

func SheetCellTypeFormula(text string) interface{}
func SheetCellTypeLink(title, link string) interface{}

SheetCellTypeLink ...

func SheetCellTypeMentionEmail

func SheetCellTypeMentionEmail(email string, notify, grantReadPermission bool) interface{}

func SheetCellTypeMentionOpenID

func SheetCellTypeMentionOpenID(openID string, notify, grantReadPermission bool) interface{}

func SheetCellTypeMentionUnionID

func SheetCellTypeMentionUnionID(unionID string, notify, grantReadPermission bool) interface{}

Types

type AddPermissionResp

type AddPermissionResp struct {
	IsAllSuccess bool                           `json:"is_all_success"`
	FailMembers  []AddPermissionRespFailMembers `json:"fail_members"`
}

type AddPermissionRespFailMembers

type AddPermissionRespFailMembers struct {
	MemberType string `json:"member_type"`
	MemberID   string `json:"member_id"`
	Perm       string `json:"perm"`
}

type AddRecordResp

type AddRecordResp struct {
	Records []Record `json:"records"`
}

type Attachment

type Attachment struct {
	// contains filtered or unexported fields
}

func (*Attachment) UpdateAll

func (a *Attachment) UpdateAll(attachmentType doctypes.AttachmentType, token, filename string, fileData []byte) (string, error)

func (*Attachment) UpdateResuming

func (a *Attachment) UpdateResuming(attachmentType doctypes.AttachmentType, token, filename string, fileSize int64, fileData io.Reader, processChan chan int64) (string, error)

type Bitable

type Bitable struct {
	Err error
	// contains filtered or unexported fields
}

Doc represent a doc file

func (*Bitable) GetToken

func (t *Bitable) GetToken() string

func (*Bitable) Table

func (b *Bitable) Table(id string) *Table

type Children

type Children struct {
	Token string   `json:"token"`
	Name  string   `json:"name"`
	Type  FileType `json:"type"`
}

type ChildrenInfo

type ChildrenInfo struct {
	ParentToken string              `json:"parentToken"`
	Children    map[string]Children `json:"children"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for docs sdk, support sheet, doc and so on

func NewClient

func NewClient(appID, appSecret string, ops ...ClientOption) *Client

NewClient create a client with app id and app secret.

func (*Client) CommonReq

func (c *Client) CommonReq(_req *http.Request, dst interface{}) ([]byte, error)

CommonReq provide comment http request

func (*Client) DoRequest

func (c *Client) DoRequest(_req *http.Request, dst interface{}) ([]byte, error)

DoRequest set authorization header and send request

func (*Client) GetMeta

func (c *Client) GetMeta(token, typ, userIDType string) (*MetaRespMetas, error)

func (*Client) OpenBitable

func (c *Client) OpenBitable(token string) *Bitable

func (*Client) OpenDoc

func (c *Client) OpenDoc(token string) *Doc

Doc for doc operation Note

in a doc url, for example: https://abc.feishu.cn/docs/doccnuqdJJqnJ0LLWOjxoTS2Rld, doccnuqdJJqnJ0LLWOjxoTS2Rld is the token

func (*Client) OpenDocx

func (c *Client) OpenDocx(token string) *Docx

Docx for doc operation Note

in a docx url, for example: https://abc.feishu.cn/docs/doccnuqdJJqnJ0LLWOjxoTS2Rld, doccnuqdJJqnJ0LLWOjxoTS2Rld is the token

func (*Client) OpenFolder

func (c *Client) OpenFolder(token string) *Folder

Folder for folder operation Note

in a folder url, for example: https://abc.feishu.cn/drive/folder/fldcnNhbqOyI0PVEPCuKa0acocdb, fldcnNhbqOyI0PVEPCuKa0acocdb is the token

func (*Client) OpenSpreadSheets

func (c *Client) OpenSpreadSheets(spreadSheetToken string) *SpreadSheets

SpreadSheets is for Sheets use Parameter

spreadSheetToken: token of a spreadsheets.

Note

in a spreadsheets url, for example: https://abc.feishu.cn/sheets/shtcnjvusYPizPzZ8JqIWyCP7ca, shtcnjvusYPizPzZ8JqIWyCP7ca is the token

func (*Client) OpenWiki added in v0.2.8

func (c *Client) OpenWiki(token string) *Wiki

func (*Client) RootFolder

func (c *Client) RootFolder() *Folder

RootFolder get root folder of the bot/user

type ClientOption

type ClientOption func(c *Client)

ClientOption Client option parameters

func WithDomain

func WithDomain(domain string) ClientOption

WithDomain set domain for api, default is https://open.feishu.cn

func WithProxy

func WithProxy(proxyURL *url.URL, insecureSkipVerify bool) ClientOption

WithProxy add http proxy

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout set http request timeout

func WithTokenGetter

func WithTokenGetter(f func() (token string, expireTime int64, err error)) ClientOption

WithTokenGetter set a function to getting the token.

type DimensionRangeDeleteResp

type DimensionRangeDeleteResp struct {
	DelCount       int                `json:"delCount"`
	MajorDimension MajorDimensionType `json:"majorDimension"`
}

type DimensionRangePutResp

type DimensionRangePutResp = interface{} // there is no document, for future use.

type DimensionRangeResp

type DimensionRangeResp struct {
	AddCount       int    `json:"addCount"`
	MajorDimension string `json:"majorDimension"`
}

type Doc

type Doc struct {
	Err error
	// contains filtered or unexported fields
}

Doc represent a doc file

func (*Doc) AddWholeComment

func (d *Doc) AddWholeComment(content string) (*RespComment, error)

func (*Doc) ChangeOwner

func (d *Doc) ChangeOwner(newOwner *Member, removeOldOwner, notify bool) *Doc

func (*Doc) GetContent

func (d *Doc) GetContent() ([]byte, *DocContent, int, error)

func (*Doc) GetMeta

func (d *Doc) GetMeta() (*DocMeta, error)

GetMeta for doc meta info

func (*Doc) GetToken

func (t *Doc) GetToken() string

func (*Doc) SetAccessPermission

func (d *Doc) SetAccessPermission(per string) *Doc

func (*Doc) Share

func (d *Doc) Share(perm Perm, notify bool, members ...*Member) *Doc

Share to other user or group.

func (*Doc) Statistics added in v0.2.8

func (d *Doc) Statistics() (*FileStatistics, error)

type DocContent

type DocContent struct {
	Title *doctypes.Title `json:"title"`
	Body  *doctypes.Body  `json:"body"`
}

type DocDeleteFlag

type DocDeleteFlag int
var (
	DocDeleteFlagNormal  DocDeleteFlag = 0
	DocDeleteFlagTrashed DocDeleteFlag = 1
	DocDeleteFlagDeleted DocDeleteFlag = 2
)

func (DocDeleteFlag) MarshalJSON

func (d DocDeleteFlag) MarshalJSON() ([]byte, error)

func (*DocDeleteFlag) UnmarshalJSON

func (d *DocDeleteFlag) UnmarshalJSON(data []byte) error

type DocMeta

type DocMeta struct {
	CreateDate     string        `json:"create_date"`
	CreateTime     int           `json:"create_time"`
	CreateUID      string        `json:"create_uid"`
	CreateUserName string        `json:"create_user_name"`
	DeleteFlag     DocDeleteFlag `json:"delete_flag"`
	EditTime       int64         `json:"edit_time,string"`
	EditUserName   string        `json:"edit_user_name"`
	IsExternal     bool          `json:"is_external"`
	IsPined        bool          `json:"is_pined"`
	IsStared       bool          `json:"is_stared"`
	ObjType        string        `json:"obj_type"`
	OwnerID        string        `json:"owner_id"`
	OwnerUserName  string        `json:"owner_user_name"`
	ServerTime     int           `json:"server_time"`
	TenantID       string        `json:"tenant_id"`
	Title          string        `json:"title"`
	Type           int           `json:"type"`
	URL            string        `json:"url"`
}

type Docx

type Docx struct {
	Err error
	// contains filtered or unexported fields
}

Docx represent a doc file

func (*Docx) GetMeta

func (d *Docx) GetMeta() (*MetaRespMetas, error)

func (*Docx) GetToken

func (t *Docx) GetToken() string

func (*Docx) Statistics added in v0.2.8

func (d *Docx) Statistics() (*FileStatistics, error)

type Err

type Err struct {
	Meta Meta   `json:"meta"`
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func GetRawErr

func GetRawErr(err error) (*Err, bool)

func (*Err) Error

func (e *Err) Error() string

type Field

type Field = map[string]interface{}

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Copy

func (f *File) Copy(srcFileToken string, srcFileType FileType, dstFolderToken, dstTitle string, copyComment bool) ([]byte, *RespCopyFile, error)

Copy a file reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uYTN5UjL2UTO14iN1kTN 复制一个文档 参考 https://open.feishu.cn/document/ukTMukTMukTM/uYTNzUjL2UzM14iN1MTN

func (*File) Create

func (f *File) Create(folderToken, title string, fileType FileType) (*RespCreateFile, error)

Create a doc or sheet reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uUTN5UjL1UTO14SN1kTN 创建一个文件 参考 https://open.feishu.cn/document/ukTMukTMukTM/uQTNzUjL0UzM14CN1MTN

func (*File) UpdateAll

func (f *File) UpdateAll(parentType ParentType, parentNode, filename string, fileData []byte) (string, error)

UpdateAll Return

1: token of the file

func (*File) UpdateResumed

func (f *File) UpdateResumed(parentType ParentType, parentNode, filename string, fileSize int64, fileData io.Reader, processChan chan int64) (string, error)

type FileStatistics added in v0.2.8

type FileStatistics struct {
	FileToken  string `json:"file_token"`
	FileType   string `json:"file_type"`
	Statistics Stats  `json:"statistics"`
}

type FileType

type FileType = string

FileType represent a document type of docs.

var (
	FileTypeDoc      FileType = "doc"
	FileTypeDocx     FileType = "docx"
	FileTypeSheet    FileType = "sheet"
	FileTypeWiki     FileType = "wiki"
	FileTypeSlide    FileType = "slide"
	FileTypeBitable  FileType = "bitable"
	FileTypeMindNote FileType = "mindnote"
	FileTypeFolder   FileType = "folder"
)

type Folder

type Folder struct {
	Err error // used for save error information
	// contains filtered or unexported fields
}

Folder represent a folder instance

func (*Folder) Children

func (f *Folder) Children(fileTypes []FileType) (*ChildrenInfo, error)

func (*Folder) CreateDoc

func (f *Folder) CreateDoc(title *doctypes.Title, body *doctypes.Body) (doc *Doc)

CreateDoc for create a document

func (*Folder) CreateSpreadSheet

func (f *Folder) CreateSpreadSheet(title string) (ss *SpreadSheets)

CreateSpreadSheet ...

func (*Folder) CreateSubFolder

func (f *Folder) CreateSubFolder(title string) *Folder

CreateSubFolder to create a child folder in the current folder Return

1: the child folder instance

func (*Folder) GetMeta

func (f *Folder) GetMeta() (*FolderMeta, error)

GetMeta to get the meta information of folder

func (*Folder) GetToken

func (t *Folder) GetToken() string

func (*Folder) UpdateFileResumed

func (f *Folder) UpdateFileResumed(filename string, fileSize int64, fileData io.Reader, processChan chan int64) (string, error)

UpdateFileResumed is used for uploading big file

func (*Folder) UploadFile

func (f *Folder) UploadFile(filename string, fileData []byte) (string, error)

UploadFile is used for uploading small file(less than 20MB)

type FolderMeta

type FolderMeta struct {
	ID        string `json:"id"` // id of the folder
	Name      string `json:"name"`
	Token     string `json:"token"`
	CreateUID string `json:"createUid"` // user id of the create user id
	EditUID   string `json:"editUid"`
	ParentID  string `json:"parentId"`
	OwnUID    string `json:"ownUid"`
}

type GetValuesByRangeMultiResp

type GetValuesByRangeMultiResp struct {
	Revision         int                                    `json:"revision"`
	SpreadsheetToken string                                 `json:"spreadsheetToken"`
	TotalCells       int                                    `json:"totalCells"`
	ValueRanges      []GetValuesByRangeMultiRespValueRanges `json:"valueRanges"`
}

type GetValuesByRangeMultiRespValueRanges

type GetValuesByRangeMultiRespValueRanges struct {
	MajorDimension string          `json:"majorDimension"`
	Range          string          `json:"range"`
	Revision       int             `json:"revision"`
	Values         [][]interface{} `json:"values"`
}

type GetValuesByRangeResp

type GetValuesByRangeResp struct {
	Revision         int                            `json:"revision"`
	SpreadsheetToken string                         `json:"spreadsheetToken"`
	ValueRange       GetValuesByRangeRespValueRange `json:"valueRange"`
}

type GetValuesByRangeRespValueRange

type GetValuesByRangeRespValueRange struct {
	MajorDimension string          `json:"majorDimension"`
	Range          string          `json:"range"`
	Revision       int             `json:"revision"`
	Values         [][]interface{} `json:"values"`
}

type InheritStyleType

type InheritStyleType = string
var (
	InheritStyleBefore InheritStyleType = "BEFORE"
	InheritStyleAfter  InheritStyleType = "AFTER"
)

type InseartDataOptionType

type InseartDataOptionType = string
var (
	InseartDataOptionOverwrite  InseartDataOptionType = "OVERWRITE"
	InseartDataOptionInsertRows InseartDataOptionType = "INSERT_ROWS"
)

type MajorDimensionType

type MajorDimensionType = string
var (
	MajorDimensionRows    MajorDimensionType = "ROWS"
	MajorDimensionColumns MajorDimensionType = "COLUMNS"
)

type Member

type Member struct {
	MemberType string `json:"member_type"`
	MemberID   string `json:"member_id"`
}

func NewMemberWithEmail

func NewMemberWithEmail(email string) *Member

func NewMemberWithOpenChatID

func NewMemberWithOpenChatID(openChatID string) *Member

func NewMemberWithOpenID

func NewMemberWithOpenID(openID string) *Member

NewMemberWithOpenID Parameter

openID: is open user id. you can get it here(https://open.feishu.cn/document/home/user-identity-introduction/how-to-get)

func NewMemberWithUserID

func NewMemberWithUserID(userID string) *Member

func Newopendepartmentid

func Newopendepartmentid(opendepartmentid string) *Member

type Meta

type Meta struct {
	RequestID string `json:"request_id"`
	TTLogID   string `json:"tt_log_id"`
	TraceHost string `json:"trace_host"`
	TraceTag  string `json:"trace_tag"`
}

type MetaInfoResp

type MetaInfoResp struct {
	Properties       metaProp    `json:"properties"`
	Sheets           []sheetMeta `json:"sheets"`
	SpreadsheetToken string      `json:"spreadsheetToken"`
}

type MetaResp

type MetaResp struct {
	Metas      []*MetaRespMetas      `json:"metas"`
	FailedList []*MetaRespFailedList `json:"failed_list"`
}

type MetaRespFailedList

type MetaRespFailedList struct {
	Token string `json:"token"`
	Code  int    `json:"code"`
}

type MetaRespMetas

type MetaRespMetas struct {
	DocToken         string `json:"doc_token"`
	DocType          string `json:"doc_type"`
	Title            string `json:"title"`
	OwnerID          string `json:"owner_id"`
	CreateTime       int64  `json:"create_time,string"`
	LatestModifyUser string `json:"latest_modify_user"`
	LatestModifyTime int64  `json:"latest_modify_time,string"`
	URL              string `json:"url"`
	SecLabelName     string `json:"sec_label_name"`
}

type ModifyProperties

type ModifyProperties struct {
	SheetID *string        `json:"sheetId,omitempty"`
	Title   *string        `json:"title,omitempty"`
	Index   *int           `json:"index,omitempty"`
	Hidden  *bool          `json:"hidden,omitempty"`
	Protect *ModifyProtect `json:"protect,omitempty"`
}

type ModifyProtect

type ModifyProtect struct {
	Lock     *string `json:"lock,omitempty"`
	LockInfo *string `json:"lockInfo,omitempty"`
	UserIds  []int64 `json:"userIds,omitempty"`
}

type ModifySheet

type ModifySheet struct {
	Properties *ModifyProperties `json:"properties,omitempty"`
}

type ModifySheetType

type ModifySheetType = string
var (
	ModifySheetAdd    ModifySheetType = "addSheet"
	ModifySheetCopy   ModifySheetType = "copySheet"
	ModifySheetDelete ModifySheetType = "deleteSheet"
	ModifySheetUpdate ModifySheetType = "updateSheet"
)

type ParentType

type ParentType = string
var (
	ParentTypeExplorer ParentType = "explorer"
)

type Perm

type Perm string
const (
	PermView Perm = "view"
	PermEdit Perm = "edit"
	PermFull Perm = "full_access"
)

type PublicSet

type PublicSet struct {
	Token           string  `json:"token"`
	Type            string  `json:"type"`
	SecurityEntity  *string `json:"security_entity,omitempty"`
	CommentEntity   *string `json:"comment_entity,omitempty"`
	ShareEntity     *string `json:"share_entity,omitempty"`
	LinkShareEntity *string `json:"link_share_entity,omitempty"`
	ExternalAccess  *bool   `json:"external_access,omitempty"`
	InviteExternal  *bool   `json:"invite_external,omitempty"`
}

type Range

type Range = string

Range reference https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#bae19f77

func NewRangeCol

func NewRangeCol(sheetID, startCol, endCol string) Range

!A:D

func NewRangeFull

func NewRangeFull(sheetID, startCellName, endCellName string) Range

!A1:D5

func NewRangeHalf

func NewRangeHalf(sheetID, startCellName, endCol string) Range

!A1:D

func NewRangeSheetID

func NewRangeSheetID(sheetID string) Range

!<sheetID>

type Record

type Record struct {
	Fields   Field  `json:"fields"`
	ID       string `json:"id,omitempty"`
	RecordID string `json:"record_id,omitempty"`
}

type RespComment

type RespComment struct {
	CommentID       string `json:"comment_id"`
	ReplyID         string `json:"reply_id"`
	CreateTimestamp int64  `json:"create_timestamp"`
	UpdateTimestamp int64  `json:"update_timestamp"`
}

type RespCopyFile

type RespCopyFile struct {
	FolderToken string `json:"folderToken"`
	Revision    int    `json:"revision"`
	Token       string `json:"token"`
	Type        string `json:"type"`
	URL         string `json:"url"`
}

type RespCreateDoc

type RespCreateDoc struct {
	ObjToken string `json:"objToken"`
	URL      string `json:"url"`
}

type RespCreateFile

type RespCreateFile = RespCreateFoler

type RespCreateFoler

type RespCreateFoler struct {
	URL      string `json:"url"`
	Revision int    `json:"revision"`
	Token    string `json:"token"`
}

type RootFolderResp

type RootFolderResp struct {
	Token  string `json:"token"`
	ID     string `json:"id"`
	UserID string `json:"user_id"`
}

type Sheet

type Sheet struct {
	Err error
	// contains filtered or unexported fields
}

Sheet represent a sheet tab in spread sheets(SpreadSheets)

func (*Sheet) FrozenColumn

func (s *Sheet) FrozenColumn(column int) *Sheet

FrozenColumn Parameter

column: number of column that want to frezen. 0 represent unfrozen

func (*Sheet) FrozenRow

func (s *Sheet) FrozenRow(row int) *Sheet

FrozenRow Parameter

row: number of row that want to frezen. 0 represent unfrozen

func (*Sheet) GetContentByRange

func (s *Sheet) GetContentByRange(startCellname, endCellname string) (*SheetContent, error)

func (*Sheet) GetContentByRangeV2

func (s *Sheet) GetContentByRangeV2(startCellname, endCellname string, render SheetRenderOption, dateTime SheetDateTimeRenderOption) (*SheetContent, error)

GetContentByRangeV2 Reference https://open.feishu.cn/document/ukTMukTMukTM/ugTMzUjL4EzM14COxMTN

func (*Sheet) GetID

func (s *Sheet) GetID() string

func (*Sheet) Hidden

func (s *Sheet) Hidden(hidden bool) *Sheet

func (*Sheet) MoveColumns

func (s *Sheet) MoveColumns(start, end, target int) *Sheet

MoveColumns start with 1

func (*Sheet) MoveRows

func (s *Sheet) MoveRows(start, end, target int) *Sheet

MoveRows start with 1

func (*Sheet) NewRangeFull

func (s *Sheet) NewRangeFull(startCellName, endCellName string) *SheetRange

!A1:D5

func (*Sheet) Protect

func (s *Sheet) Protect(info string, userIDs []string) *Sheet

func (*Sheet) ReadRows

func (s *Sheet) ReadRows() ([]SheetRow, error)

ReadRows for get all rows

func (*Sheet) TrimBlankTail

func (s *Sheet) TrimBlankTail(rows []SheetRow) []SheetRow

func (*Sheet) UpdateIndex

func (s *Sheet) UpdateIndex(index int) *Sheet

UpdateIndex ...

func (*Sheet) UpdateTitle

func (s *Sheet) UpdateTitle(title string) *Sheet

UpdateTitle ...

func (*Sheet) WriteRows

func (s *Sheet) WriteRows(data [][]interface{}, batchCount ...int) *Sheet

WriteRows write rows line by line, start from A1 cell

func (*Sheet) WriteRowsByStartCell

func (s *Sheet) WriteRowsByStartCell(startCell string, title []string, data [][]interface{}, batchCount ...int) *Sheet

WriteRowsByStartCell Parameter

title: title of every columns.
batchCount: max insert line coune once.

Example

s.WriteRowsByStartCell("A1",[]string{"name", "age"}, [][]interface{}{
	{"Ace",15},
	{"Bob",16},
},10)

type SheetBatchUpdateResp

type SheetBatchUpdateResp struct {
	Replies []SheetBatchUpdateRespReplies `json:"replies"`
}

type SheetBatchUpdateRespAddSheet

type SheetBatchUpdateRespAddSheet struct {
	Properties SheetBatchUpdateRespProperties `json:"properties"`
}

type SheetBatchUpdateRespCopySheet

type SheetBatchUpdateRespCopySheet struct {
	Properties SheetBatchUpdateRespProperties `json:"properties"`
}

type SheetBatchUpdateRespDeleteSheet

type SheetBatchUpdateRespDeleteSheet struct {
	Result  bool   `json:"result"`
	SheetID string `json:"sheetId"`
}

type SheetBatchUpdateRespProperties

type SheetBatchUpdateRespProperties struct {
	SheetID string `json:"sheetId"`
	Title   string `json:"title"`
	Index   int    `json:"index"`
}

type SheetBatchUpdateRespReplies

type SheetBatchUpdateRespReplies struct {
	AddSheet    SheetBatchUpdateRespAddSheet    `json:"addSheet"`
	CopySheet   SheetBatchUpdateRespCopySheet   `json:"copySheet"`
	UpdateSheet SheetBatchUpdateRespUpdateSheet `json:"updateSheet"`
	DeleteSheet SheetBatchUpdateRespDeleteSheet `json:"deleteSheet"`
}

type SheetBatchUpdateRespUpdateSheet

type SheetBatchUpdateRespUpdateSheet struct {
	UpdateSheet SheetBatchUpdateRespUpdateSheetUpdateSheet `json:"updateSheet"`
}

type SheetBatchUpdateRespUpdateSheetProperties

type SheetBatchUpdateRespUpdateSheetProperties struct {
	SheetID        string                                 `json:"sheetId"`
	Title          string                                 `json:"title"`
	Index          int                                    `json:"index"`
	Hidden         bool                                   `json:"hidden"`
	FrozenColCount int                                    `json:"frozenColCount"`
	FrozenRowCount int                                    `json:"frozenRowCount"`
	Protect        SheetBatchUpdateRespUpdateSheetProtect `json:"protect"`
}

type SheetBatchUpdateRespUpdateSheetProtect

type SheetBatchUpdateRespUpdateSheetProtect struct {
	Lock      string  `json:"lock"`
	SheetName string  `json:"sheetName"`
	PermID    string  `json:"permId"`
	UserIds   []int64 `json:"userIds"`
}

type SheetBatchUpdateRespUpdateSheetUpdateSheet

type SheetBatchUpdateRespUpdateSheetUpdateSheet struct {
	Properties SheetBatchUpdateRespUpdateSheetProperties `json:"properties"`
}

type SheetCell

type SheetCell struct {
	// contains filtered or unexported fields
}

SheetCell represent for a cell of sheet

func NewSheetCell

func NewSheetCell(i interface{}) *SheetCell

func (SheetCell) MarshalJSON

func (s SheetCell) MarshalJSON() ([]byte, error)

func (SheetCell) ToFloat

func (d SheetCell) ToFloat() (float64, error)

func (SheetCell) ToInt64

func (d SheetCell) ToInt64() (int64, error)

func (SheetCell) ToString

func (d SheetCell) ToString() string

func (SheetCell) Value

func (d SheetCell) Value() interface{}

type SheetCellStyle

type SheetCellStyle struct {
	Font struct {
		Bold     bool   `json:"bold,omitempty"`
		Italic   bool   `json:"italic,omitempty"`
		FontSize string `json:"fontSize,omitempty"`
		Clean    bool   `json:"clean,omitempty"`
	} `json:"font,omitempty"`
	TextDecoration int    `json:"textDecoration,omitempty"`
	Formatter      string `json:"formatter,omitempty"`
	HAlign         int    `json:"hAlign,omitempty"`
	VAlign         int    `json:"vAlign,omitempty"`
	ForeColor      string `json:"foreColor,omitempty"`
	BackColor      string `json:"backColor,omitempty"`
	BorderType     string `json:"borderType,omitempty"`
	BorderColor    string `json:"borderColor,omitempty"`
	Clean          bool   `json:"clean,omitempty"`
}

type SheetContent

type SheetContent struct {
	ValueRange struct {
		Values [][]interface{} `json:"values"`
	} `json:"valueRange"`
}

func (*SheetContent) ToRows

func (sc *SheetContent) ToRows() []SheetRow

type SheetDateTimeRenderOption

type SheetDateTimeRenderOption string
var (
	SheetDateTimeRenderFormattedString SheetDateTimeRenderOption = "FormattedString"
)

type SheetRange

type SheetRange struct {
	Err error
	// contains filtered or unexported fields
}

Range reference https://open.feishu.cn/document/ukTMukTMukTM/uczNzUjL3czM14yN3MTN#bae19f77

func (*SheetRange) Rows

func (s *SheetRange) Rows() ([]SheetRow, error)

Rows ...

func (*SheetRange) RowsParseMerge

func (s *SheetRange) RowsParseMerge() ([]SheetRow, error)

RowsParseMerge parse cell from merged cell. if a cell is merged, like below, we only get value at the first cell, others are nil. so we should fill a to every cell of the merged cell. | a | | | | | | | | | | |

func (*SheetRange) Scan

func (s *SheetRange) Scan(ptr interface{}) error

func (*SheetRange) SetDropdown

func (s *SheetRange) SetDropdown(values []string, multiple bool, colors []string) error

SetDropdown Parameter:

colors: set highlight color of values, could be nil. values like #1FB6C1

Reference:

https://open.feishu.cn/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/datavalidation/set-dropdown

type SheetRenderOption

type SheetRenderOption string
var (
	SheetRenderToString         SheetRenderOption = "ToString"
	SheetRenderFormattedValue   SheetRenderOption = "FormattedValue"
	SheetRenderFormula          SheetRenderOption = "Formula"
	SheetRenderUnformattedValue SheetRenderOption = "UnformattedValue"
)

type SheetRow

type SheetRow = []*SheetCell

SheetRow represent for a group of sheet cell

type SheetStyleResp

type SheetStyleResp struct {
	Updates SheetStyleRespUpdate `json:"updates"`
}

type SheetStyleRespUpdate

type SheetStyleRespUpdate struct {
	SpreadsheetToken string `json:"spreadsheetToken"`
	UpdatedRange     string `json:"updatedRange"`
	UpdatedRows      int    `json:"updatedRows"`
	UpdatedColumns   int    `json:"updatedColumns"`
	UpdatedCells     int    `json:"updatedCells"`
	Revision         int    `json:"revision"`
}

type SpreadSheetMeta

type SpreadSheetMeta = MetaInfoResp

SpreadsheetMeta sheet 的 meta 信息

type SpreadSheetOrigin

type SpreadSheetOrigin struct {
	// contains filtered or unexported fields
}

SpreadSheetOrigin represent for origin open API. 这个客户端的方法使用了原始的开放平台 API,没有做任何封装。

func (*SpreadSheetOrigin) DimensionRangeDelete

func (so *SpreadSheetOrigin) DimensionRangeDelete(sheetID string, majorDimension MajorDimensionType, startIndex, endIndex int) ([]byte, *DimensionRangeDeleteResp, error)

DimensionRangeDelete for delete rows or columns reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uATO2UjLwkjN14CM5YTN 删除行列 参考 https://open.feishu.cn/document/ukTMukTMukTM/ucjMzUjL3IzM14yNyMTN

func (*SpreadSheetOrigin) DimensionRangePost

func (so *SpreadSheetOrigin) DimensionRangePost(sheetID string, majorDimension MajorDimensionType, length int) ([]byte, *DimensionRangeResp, error)

func (*SpreadSheetOrigin) DimensionRangePut

func (so *SpreadSheetOrigin) DimensionRangePut(sheetID string, majorDimension MajorDimensionType, startIndex, endIndex int, visible bool, fixedSize int) ([]byte, *DimensionRangePutResp, error)

DimensionRangePut for update rows or columns reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uETO2UjLxkjN14SM5YTN 更新行列 参考 https://open.feishu.cn/document/ukTMukTMukTM/uYjMzUjL2IzM14iNyMTN

func (*SpreadSheetOrigin) Import

func (so *SpreadSheetOrigin) Import(filepath string, filename string, folderToken string) ([]byte, string, error)

Import represent import excel from local reference https://open.larksuite.com/document/ukTMukTMukTM/uATO2YjLwkjN24CM5YjN

func (*SpreadSheetOrigin) InsertDimensionRange

func (so *SpreadSheetOrigin) InsertDimensionRange(sheetID string, startIndex, endIndex int, majorDimension MajorDimensionType, inheritStyle InheritStyleType) error

func (*SpreadSheetOrigin) MetaInfo

func (so *SpreadSheetOrigin) MetaInfo() (b []byte, result *MetaInfoResp, err error)

MetaInfo api: /open-apis/sheet/v2/spreadsheets/:spreadsheetToken/metainfo reference: https://open.feishu.cn/document/ukTMukTMukTM/uETMzUjLxEzM14SMxMTN

func (*SpreadSheetOrigin) Properties

func (so *SpreadSheetOrigin) Properties(prop *SpreadSheetProperties) (b []byte, err error)

Properties reference: https://open.feishu.cn/document/ukTMukTMukTM/ucTMzUjL3EzM14yNxMTN

func (*SpreadSheetOrigin) ReadValuesByRange

func (so *SpreadSheetOrigin) ReadValuesByRange(_range Range, valueRender string, dateTimeRender string) ([]byte, *GetValuesByRangeResp, error)

ReadValuesByRange read data by range reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/ukzN2UjL5cjN14SO3YTN 读取单个范围的数据 参考 https://open.feishu.cn/document/ukTMukTMukTM/ugTMzUjL4EzM14COxMTN

func (*SpreadSheetOrigin) ReadValuesByRangeMulti

func (so *SpreadSheetOrigin) ReadValuesByRangeMulti(ranges []Range, valueRender string, dateTimeRender string) ([]byte, *GetValuesByRangeMultiResp, error)

ReadValuesByRangeMulti for reading multiple ranges reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uADO2UjLwgjN14CM4YTN 读取多个范围的数据 参考 https://open.feishu.cn/document/ukTMukTMukTM/ukTMzUjL5EzM14SOxMTN

func (*SpreadSheetOrigin) SheetBatchUpdate

func (so *SpreadSheetOrigin) SheetBatchUpdate(args map[ModifySheetType]interface{}) (b []byte, resp *SheetBatchUpdateResp, err error)

SheetBatchUpdate for update properties of a sheet reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uQDO2UjL0gjN14CN4YTN 更新 sheet 的属性 参考 https://open.feishu.cn/document/ukTMukTMukTM/ugjMzUjL4IzM14COyMTN

func (*SpreadSheetOrigin) Style

func (so *SpreadSheetOrigin) Style(_range Range, style *SheetCellStyle) (*SheetStyleResp, error)

Style ...

func (*SpreadSheetOrigin) ValuesAppend

func (so *SpreadSheetOrigin) ValuesAppend(_range Range, data [][]interface{}, inseartDataOption InseartDataOptionType) ([]byte, *ValuesPrependResp, error)

ValuesAppend reference https://open.feishu.cn/document/ukTMukTMukTM/uMjMzUjLzIzM14yMyMTN

func (*SpreadSheetOrigin) ValuesPrepend

func (so *SpreadSheetOrigin) ValuesPrepend(_range SheetRange, data [][]interface{}) ([]byte, *ValuesPrependResp, error)

ValuesPrepend reference https://open.feishu.cn/document/ukTMukTMukTM/uIjMzUjLyIzM14iMyMTN

func (*SpreadSheetOrigin) WriteValuesByRange

func (so *SpreadSheetOrigin) WriteValuesByRange(_range Range, data [][]interface{}) ([]byte, *WriteValuesByRangeResp, error)

WriteValuesByRange for writing data to a single range reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uMDO2UjLzgjN14yM4YTN 向单个范围写入数据 参考 https://open.feishu.cn/document/ukTMukTMukTM/uAjMzUjLwIzM14CMyMTN

func (*SpreadSheetOrigin) WriteValuesByRangeMulti

func (so *SpreadSheetOrigin) WriteValuesByRangeMulti(rangeDatas []*WriteValuesByRangeMultiArgs) ([]byte, *WriteValuesByRangeMultiResp, error)

WriteValuesByRangeMulti for writing data to multiple ranges reference https://open.larksuite.com/document/uMzMyEjLzMjMx4yMzITM/uIDO2UjLygjN14iM4YTN 向多个范围写入数据 参考 https://open.feishu.cn/document/ukTMukTMukTM/uEjMzUjLxIzM14SMyMTN

type SpreadSheetProperties

type SpreadSheetProperties struct {
	Title *string `json:"title,omitempty"`
}

type SpreadSheets

type SpreadSheets struct {
	Err error
	// contains filtered or unexported fields
}

SpreadSheets represent a group of sheet

func (*SpreadSheets) AddSheet

func (ss *SpreadSheets) AddSheet(title string, index int) *Sheet

AddSheet Parameter

index: first position is 0

func (*SpreadSheets) ChangeOwner

func (ss *SpreadSheets) ChangeOwner(newOwner *Member, removeOldOwner, notify bool) *SpreadSheets

func (*SpreadSheets) CopySheet

func (ss *SpreadSheets) CopySheet(sourceSheetID string, title string) (sheet *Sheet)

func (*SpreadSheets) DeleteSheet

func (ss *SpreadSheets) DeleteSheet(sheetID string) *SpreadSheets

DeleteSheet Note:

Sheet id can be found in url, for example in the url https://laily.feishu.cn/sheets/shtcnLML6348M7ujOaYd1EsUe9f?sheet=5d8cef

sheet id is 5d8cef

func (*SpreadSheets) GetMeta

func (ss *SpreadSheets) GetMeta() (res *SpreadSheetMeta, err error)

GetMeta get spread sheet meta information. 获取这个表格的元信息。

func (*SpreadSheets) GetOrigin

func (ss *SpreadSheets) GetOrigin() *SpreadSheetOrigin

GetOrigin get origin client, with is use origin open API. 获取原始客户端,这个客户端直接使用开放平台文档上的 API,没有做任何封装

func (*SpreadSheets) GetToken

func (t *SpreadSheets) GetToken() string

func (*SpreadSheets) ModifyProperties

func (ss *SpreadSheets) ModifyProperties(args *ModifyProperties) *SpreadSheets

func (*SpreadSheets) SetAccessPermission

func (ss *SpreadSheets) SetAccessPermission(per string) *SpreadSheets

func (*SpreadSheets) Share

func (ss *SpreadSheets) Share(perm Perm, notify bool, members ...*Member) *SpreadSheets

Share to other user or group.

func (*SpreadSheets) SheetID

func (ss *SpreadSheets) SheetID(sheetID string) *Sheet

SheetID get sheet by sheet id 根据 sheet id 获取 sheet 实例。

func (*SpreadSheets) SheetIndex

func (ss *SpreadSheets) SheetIndex(index int) *Sheet

SheetIndex get a sheet instance by index. Index start from 1

func (*SpreadSheets) SheetName

func (ss *SpreadSheets) SheetName(name string) *Sheet

SheetName get sheet by sheet name

func (*SpreadSheets) Statistics added in v0.2.8

func (ss *SpreadSheets) Statistics() (*FileStatistics, error)

func (*SpreadSheets) UpdateTitle

func (ss *SpreadSheets) UpdateTitle(title string) *SpreadSheets

UpdateTitle Parameter

title: tile of spreadsheet

type Stats added in v0.2.8

type Stats struct {
	UV        int64 `json:"uv"`
	PV        int64 `json:"pv"`
	LikeCount int64 `json:"like_count"`
	Timestamp int64 `json:"timestamp"`
}

type Table

type Table struct {
	Err error

	*Bitable
	// contains filtered or unexported fields
}

func (*Table) AddRecord

func (t *Table) AddRecord(data []Field) *Table

func (Table) GetToken

func (t Table) GetToken() string

type TransferOwnerResp

type TransferOwnerResp struct {
	IsSuccess bool                   `json:"is_success"`
	Token     string                 `json:"token"`
	Type      string                 `json:"type"`
	Owner     TransferOwnerRespOwner `json:"owner"`
}

type TransferOwnerRespOwner

type TransferOwnerRespOwner struct {
	MemberType string `json:"member_type"`
	MemberID   string `json:"member_id"`
}

type UpdateFileResp

type UpdateFileResp struct {
	FileToken string `json:"file_token"`
}

type ValuesPrependResp

type ValuesPrependResp struct {
	Revision         int                  `json:"revision"`
	SpreadsheetToken string               `json:"spreadsheetToken"`
	TableRange       string               `json:"tableRange"`
	Updates          ValuesPrependUpdates `json:"updates"`
}

type ValuesPrependUpdates

type ValuesPrependUpdates struct {
	SpreadsheetToken string `json:"spreadsheetToken"`
	UpdatedRange     string `json:"updatedRange"`
	UpdatedRows      int    `json:"updatedRows"`
	UpdatedColumns   int    `json:"updatedColumns"`
	UpdatedCells     int    `json:"updatedCells"`
	Revision         int    `json:"revision"`
}

type Wiki added in v0.2.8

type Wiki struct {
	Err error
	// contains filtered or unexported fields
}

Docx represent a doc file

func (*Wiki) GetMeta added in v0.2.8

func (w *Wiki) GetMeta() (*MetaRespMetas, error)

func (*Wiki) GetToken added in v0.2.8

func (t *Wiki) GetToken() string

func (*Wiki) Statistics added in v0.2.8

func (w *Wiki) Statistics() (*FileStatistics, error)

type WriteValuesByRangeMultiArgs

type WriteValuesByRangeMultiArgs struct {
	Range  Range           `json:"range"`
	Values [][]interface{} `json:"values"`
}

type WriteValuesByRangeMultiResp

type WriteValuesByRangeMultiResp struct {
	Responses        []WriteValuesByRangeMultiRespResponses `json:"responses"`
	Revision         int                                    `json:"revision"`
	SpreadsheetToken string                                 `json:"spreadsheetToken"`
}

type WriteValuesByRangeMultiRespResponses

type WriteValuesByRangeMultiRespResponses struct {
	SpreadsheetToken string `json:"spreadsheetToken"`
	UpdatedCells     int    `json:"updatedCells"`
	UpdatedColumns   int    `json:"updatedColumns"`
	UpdatedRange     string `json:"updatedRange"`
	UpdatedRows      int    `json:"updatedRows"`
}

type WriteValuesByRangeResp

type WriteValuesByRangeResp struct {
	Revision         int    `json:"revision"`
	SpreadsheetToken string `json:"spreadsheetToken"`
	UpdatedCells     int    `json:"updatedCells"`
	UpdatedColumns   int    `json:"updatedColumns"`
	UpdatedRange     string `json:"updatedRange"`
	UpdatedRows      int    `json:"updatedRows"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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