Documentation ¶
Overview ¶
Package exl
Excel binding to struct written in Go.(Only supports Go1.18+)
Index ¶
- func Read[T ReadBind](reader io.Reader, bind T, filterFunc ...func(t T) (add bool)) ([]T, error)
- func ReadBinary[T ReadBind](bytes []byte, bind T, filterFunc ...func(t T) (add bool)) ([]T, error)
- func ReadExcel(file string, sheetIndex int, walk func(index int, rows *xlsx.Row)) error
- func ReadFile[T ReadBind](file string, bind T, filterFunc ...func(t T) (add bool)) ([]T, error)
- func Write[T WriteBind](file string, ts []T) error
- func WriteExcel(file string, data [][]string) error
- type ReadBind
- type ReadMetadata
- type WriteBind
- type WriteMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Read ¶
Read defines read io.Reader each row bind to `T`
params: file,excel file full path
params: typed parameter T, must be implements exl.Bind
params: filterFunc, filter callback func
func ReadBinary ¶
ReadBinary defines read binary each row bind to `T`
params: file,excel file full path
params: typed parameter T, must be implements exl.Bind
params: filterFunc, filter callback func
func ReadExcel ¶
ReadExcel defines read walk func from excel
params: file, excel file pull path
params: sheetIndex, current sheet index
params: walk, walk func
func ReadFile ¶
ReadFile defines read excel each row bind to `T`
params: file,excel file full path
params: typed parameter T, must be implements exl.Bind
params: filterFunc, filter callback func
func Write ¶
Write defines write []T to excel file
params: file,excel file full path
params: typed parameter T, must be implements exl.Bind
func WriteExcel ¶
WriteExcel defines write [][]string to excel
params: file, excel file pull path
params: data, write data to excel
Types ¶
type ReadBind ¶
type ReadBind interface{ ReadMetadata() *ReadMetadata }
ReadBind defines read bind metadata
type ReadMetadata ¶
type ReadMetadata struct { TagName string // TagName: tag name SheetIndex int // SheetIndex: read sheet index HeaderRowIndex int // HeaderRowIndex: sheet header row index DataStartRowIndex int // DataStartRowIndex: sheet data start row index TrimSpace bool // TrimSpace: trim space left and right only on `string` type }
ReadMetadata defines read metadata
type WriteBind ¶
type WriteBind interface{ WriteMetadata() *WriteMetadata }
WriteBind defines write bind metadata
type WriteMetadata ¶
type WriteMetadata struct { SheetName string // SheetName: default sheet name TagName string // TagName: tag name }
WriteMetadata defines write metadata