Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrConnectNotOpened means can not open connect to excel. ErrConnectNotOpened = errors.New("connect should opened") // ErrWorkbookNotExist means can not found the workbook of excel. ErrWorkbookNotExist = errors.New("parse xlsx file failed: xl/workbook.xml not exist") ErrSharedStringsNotExist = errors.New("parse xlsx file failed: xl/sharedStringPaths.xml not exist") // ErrInvalidConatiner means can not using the container. ErrInvalidConatiner = errors.New("container should be ptr to slice") // ErrEmptyRow means the row is empty. ErrEmptyRow = errors.New("empty row") // ErrNoRow means there is no row. ErrNoRow = errors.New("no row") // ErrScanNil means scan nil. ErrScanNil = errors.New("scan(nil)") )
Functions ¶
func UnmarshalXLSX ¶
UnmarshalXLSX unmarshal a sheet of XLSX file into a slice container. The sheet name will be inferred from element of container If container implement the function of GetXLSXSheetName()string, the return string will used. Oterwise will use the reflect struct name.
Types ¶
type Config ¶
type Config struct { // sheet: if sheet is string, will use sheet as sheet name. // if sheet is a object implements `GetXLSXSheetName()string`, the return value will be used. // otherwise, will use sheet as struct and reflect for it's name. // if sheet is a slice, the type of element will be used to infer like before. Sheet interface{} // Use the index row as title, every row before title-row will be ignore, default is 0. TitleRowIndex int // Skip n row after title, default is 0 (not skip), empty row is not counted. Skip int // Auto prefix to sheet name. Prefix string // Auto suffix to sheet name. Suffix string }
Config of connecter
type Connecter ¶
type Connecter interface { // Open a file of excel Open(filePath string) error // Close file reader Close() error // Get all sheets name GetSheetNames() []string // Generate an new reader of a sheet // sheetNamer: if sheetNamer is string, will use sheet as sheet name. // if sheetNamer is a object implements `GetXLSXSheetName()string`, the return value will be used. // otherwise, will use sheetNamer as struct and reflect for it's name. // if sheetNamer is a slice, the type of element will be used to infer like before. NewReader(sheetNamer interface{}) (Reader, error) // Generate an new reader of a sheet // sheetNamer: if sheetNamer is string, will use sheet as sheet name. // if sheetNamer is a object implements `GetXLSXSheetName()string`, the return value will be used. // otherwise, will use sheetNamer as struct and reflect for it's name. // if sheetNamer is a slice, the type of element will be used to infer like before. MustReader(sheetNamer interface{}) Reader NewReaderByConfig(config *Config) (Reader, error) MustReaderByConfig(config *Config) Reader }
An Connecter of excel file
func NewConnecter ¶
func NewConnecter() Connecter
NewConnecter make a new connecter to connect to a exist xlsx file.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.