excelizemapper

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2025 License: MIT Imports: 8 Imported by: 0

README

excelize-mapper

Set excel data by go tag.

refer to https://github.com/qax-os/excelize/issues/619

Example

example

API

TODO

  • Improve doc.
  • Improve test coverage.
  • Add test snapshot.
  • Read file by go tag.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SliceFormatter

func SliceFormatter(val interface{}) string

Return array in format: "1, 2, 3, ...".

 How to use:
 In struct use excelize-mapper:"format:slice;"
 and
 m := excelizemapper.NewExcelizeMapper(
		excelizemapper.WithFormatter("slice", excelizemapper.SliceFormatter),
	)

Types

type Column

type Column struct {
	HeaderName   string
	ColumnWidth  float64
	ColumnIndex  int
	DefaultValue string
	FormatterKey string
	FieldName    string
}

type DynamicRules

type DynamicRules struct {
	Mappings        map[string]string
	ValueField      string
	ParentFieldName string
	ParentRule      string
}

type ExcelizeMapper

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

func NewExcelizeMapper

func NewExcelizeMapper(opts ...Option) ExcelizeMapper

func (*ExcelizeMapper) SetData

func (em *ExcelizeMapper) SetData(f *excelize.File, sheet string, slice interface{}) error

func (*ExcelizeMapper) SetFormatter

func (em *ExcelizeMapper) SetFormatter(name string, format Format)

type Format

type Format func(interface{}) string

type Option

type Option func(o *options)

func WithAutoSort

func WithAutoSort(autoSort bool) Option

WithAutoSort set auto sort

if auto sort is false, use tag index. default is true.

func WithDefaultWidth

func WithDefaultWidth(width float64) Option

WithDefaultWidth set default width

func WithFormatter

func WithFormatter(name string, format Format) Option

WithFormatter set formatter

func WithTagKey

func WithTagKey(tagKey string) Option

WithTagKey set tag key

default is "excelize-mapper"

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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