Documentation ¶
Index ¶
- Variables
- func SetHeaderNormalizer(f Normalizer)
- func SetXLSReader(xlsReader func(io.Reader) XLSReader)
- func UnmarshalExcelize(f *excelize.File, sheet string, out interface{}) error
- func UnmarshalFile(filename string, sheetName string, out interface{}) error
- type Decoder
- type ErrorHandler
- type NoUnmarshalFuncError
- type Normalizer
- type ParseError
- type SimpleDecoder
- type TypeUnmarshalXLSWithFields
- type TypeUnmarshaller
- type XLSReader
Constants ¶
This section is empty.
Variables ¶
var ( //ErrEmptyFile is an error type ErrEmptyFile = errors.New("empty xls file given") //ErrNoStructTags error type if no tags are found ErrNoStructTags = errors.New("no xls struct tags found") )
var ( ErrQuote = errors.New("extraneous or missing \" in quoted-field") ErrFieldCount = errors.New("wrong number of fields") )
These are the errors that can be returned in ParseError.Err.
var FailIfDoubleHeaderNames = false
FailIfDoubleHeaderNames indicates whether it is considered an error when a header name is repeated in the xls header.
var FailIfUnmatchedStructTags = false
FailIfUnmatchedStructTags indicates whether it is considered an error when there is an unmatched struct tag.
var ShouldAlignDuplicateHeadersWithStructFieldOrder = false
ShouldAlignDuplicateHeadersWithStructFieldOrder indicates whether we should align duplicate XLS headers per their alignment in the struct definition.
var TagName = "xls"
TagName defines key in the struct field's tag to scan
var TagSeparator = ","
TagSeparator defines seperator string for multiple xls tags in struct fields
var UseColumnHeader = true
UseColumnHeader suggests that we try and pull the column name (row 0 in excelize) vs. row 1 in excellize = first visible row
Functions ¶
func SetHeaderNormalizer ¶
func SetHeaderNormalizer(f Normalizer)
SetHeaderNormalizer sets the normalizer used to normalize struct and header field names.
func SetXLSReader ¶
SetXLSReader sets the XLS reader used to parse XLS.
func UnmarshalExcelize ¶
UnmarshalExcelize will take an excelize opened XML file and marshal to an interface
func UnmarshalFile ¶
UnmarshalFile parses the XLS from the file in the interface.
Types ¶
type Decoder ¶
type Decoder interface {
// contains filtered or unexported methods
}
Decoder interface
type NoUnmarshalFuncError ¶
type NoUnmarshalFuncError struct {
// contains filtered or unexported fields
}
NoUnmarshalFuncError is the custom error type to be raised in case there is no unmarshal function defined on type
func (NoUnmarshalFuncError) Error ¶
func (e NoUnmarshalFuncError) Error() string
type Normalizer ¶
Normalizer is a function that takes and returns a string. It is applied to struct and header field values before they are compared. It can be used to alter names for comparison. For instance, you could allow case insensitive matching or convert '-' to '_'.
func DefaultNameNormalizer ¶
func DefaultNameNormalizer() Normalizer
DefaultNameNormalizer is a nop Normalizer.
type ParseError ¶
type ParseError struct { StartLine int // Line where the record starts Line int // Line where the error occurred Column int // Column (rune index) where the error occurred Err error // The actual error }
A ParseError is returned for parsing errors. Line numbers are 1-indexed and columns are 0-indexed.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type SimpleDecoder ¶
type SimpleDecoder interface {
// contains filtered or unexported methods
}
SimpleDecoder interface
type TypeUnmarshalXLSWithFields ¶
TypeUnmarshalXLSWithFields can be implemented on whole structs to allow for whole structures to customized internal vs one off fields
type TypeUnmarshaller ¶
TypeUnmarshaller is implemented by any value that has an UnmarshalXLS method This converter is used to convert a string to your value representation of that string