Documentation
¶
Overview ¶
Package excelstruct provides a reading and writing XLSX files using structs.
Index ¶
- Constants
- Variables
- type ConvertValueError
- type DataValidation
- type Decoder
- type DecoderOptions
- type Encoder
- type EncoderOptions
- type InvalidUnmarshalError
- type MarshalerError
- type NameStyle
- type OpenFileOptions
- type Orientation
- type Read
- type ReadBoolConv
- type ReadStringConv
- type ReadTimeConv
- type ScaleAutoWidth
- type TitleConv
- type TitleMaxWidth
- type UnmarshalError
- type UnmarshalTypeError
- type UnsupportedTypeError
- type ValueMarshaler
- type ValueUnmarshaler
- type Write
- type WriteBoolConv
- type WriteFileOptions
- type WriteStringConv
Constants ¶
const DefaultSheetName = "Sheet1"
Variables ¶
var DefaultScaleAutoWidth = ScaleAutoWidth(func(len int) float64 { return float64(len) + 2.0 })
DefaultScaleAutoWidth is the scale function for default font size.
Functions ¶
This section is empty.
Types ¶
type ConvertValueError ¶
An ConvertValueError describes a value that was cannot convert to a specific user value.
func (*ConvertValueError) Error ¶
func (e *ConvertValueError) Error() string
type DataValidation ¶
DataValidation is the function to set in cell data validation.
type Decoder ¶
type Decoder[T any] struct { *excelize.File // contains filtered or unexported fields }
Decoder is a workspace for reading data from a file.
func NewDecoder ¶
func NewDecoder[T any](r *Read, opts DecoderOptions) (*Decoder[T], error)
NewDecoder creates a decoder with the specified titles and struct.
type DecoderOptions ¶
type DecoderOptions struct { SheetName string TitleRowIndex int TitleConv TitleConv StringConv ReadStringConv BoolConv ReadBoolConv TimeConv ReadTimeConv StructTag string }
DecoderOptions is the options for read workspace.
type Encoder ¶
type Encoder[T any] struct { *excelize.File // contains filtered or unexported fields }
Encoder is a writing data to a file.
func NewEncoder ¶
func NewEncoder[T any](w *Write, opts EncoderOptions) (*Encoder[T], error)
NewEncoder creates encoder the specified titles and struct.
type EncoderOptions ¶
type EncoderOptions struct { SheetName string TitleRowIndex int TitleName []string DisallowUnknownFields bool TitleConv TitleConv TitleMaxWidth TitleMaxWidth TitleScaleAutoWidth ScaleAutoWidth DataValidation DataValidation ValidationOverRow int StringConv WriteStringConv BoolConv WriteBoolConv Orientation Orientation CellNumFmt map[excelize.CellType]int TitleNumFmt map[string]int CellStyle *excelize.Style Style NameStyle TitleStyle map[string]string // map[title]style }
EncoderOptions is the options for write workspace.
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type MarshalerError ¶
type MarshalerError struct { Type reflect.Type Err error // contains filtered or unexported fields }
A MarshalerError represents an error from calling a MarshalXLSXValue.
func (*MarshalerError) Error ¶
func (e *MarshalerError) Error() string
func (*MarshalerError) Unwrap ¶
func (e *MarshalerError) Unwrap() error
Unwrap returns the underlying error.
type NameStyle ¶
type NameStyle map[string]excelize.Style
NameStyle is the naming style to quick search style.
type OpenFileOptions ¶
OpenFileOptions is the options for open file.
type Orientation ¶
type Orientation string
const ( OrientationRow Orientation = "row" OrientationColumn Orientation = "col" )
type ReadBoolConv ¶
ReadBoolConv is the function to convert value to bool.
type ReadStringConv ¶
ReadStringConv is the function to convert value to string.
type ReadTimeConv ¶
ReadTimeConv is the function to convert value to time.Time.
type ScaleAutoWidth ¶
ScaleAutoWidth is a scale function for auto width.
type TitleMaxWidth ¶
TitleMaxWidth is the function to set in cell max width. (0 - disable, -1 - no limit).
type UnmarshalError ¶
An UnmarshalError describes an error that was occurred during unmarshal.
func (*UnmarshalError) AsConvertValueError ¶
func (e *UnmarshalError) AsConvertValueError() []ConvertValueError
AsConvertValueError returns the all ConvertValueError in UnmarshalError.
func (*UnmarshalError) AsTypeError ¶
func (e *UnmarshalError) AsTypeError() []UnmarshalTypeError
AsTypeError returns the all UnmarshalTypeError in UnmarshalError.
func (*UnmarshalError) Error ¶
func (e *UnmarshalError) Error() string
Error returns the all error in UnmarshalError.
type UnmarshalTypeError ¶
type UnmarshalTypeError struct { Value string // description of string value - "bool", "array", "number -5" Type reflect.Type // type of Go value it could not be assigned to Field string // the full path from root node to the field Err error // the error returns convert function string to type }
An UnmarshalTypeError describes a EXCEL value that was not appropriate for a value of a specific Go type.
func (*UnmarshalTypeError) Error ¶
func (e *UnmarshalTypeError) Error() string
type UnsupportedTypeError ¶
An UnsupportedTypeError is returned by Marshal when attempting to encode an unsupported value type.
func (*UnsupportedTypeError) Error ¶
func (e *UnsupportedTypeError) Error() string
type ValueMarshaler ¶
ValueMarshaler is the interface implemented by an object that can marshal value itself into a string form.
type ValueUnmarshaler ¶
ValueUnmarshaler is the interface implemented by an object that can unmarshal value a string representation of itself.
type Write ¶
type Write struct { *excelize.File // contains filtered or unexported fields }
func WriteFile ¶
func WriteFile(opts WriteFileOptions) (*Write, error)
WriteFile writes a xlsx file.
type WriteBoolConv ¶
WriteBoolConv is the function to convert bool to string.
type WriteFileOptions ¶
WriteFileOptions is the options for write file.