Documentation
¶
Index ¶
- Constants
- func ReadFileStreamToList[T any](r io.Reader, sheetIndex int) (resultData []T, err error)
- func ReadFileToList[T any](filePath string, sheetIndex int) (resultData []T, err error)
- func WriteToFile[T any](n string, dataList []T) (*excelize.File, error)
- type Callback
- type ExcelFields
- type ExcelStruct
- type FieldsModel
Constants ¶
View Source
const ( DatePattern = "2006-01-02" DateTimePattern = "2006-01-02 15:04:05" TagCustomKey = "gxlsx" TagCustomTitleKey = "title" TagCustomIndexKey = "index" TagCustomFormatKey = "format" )
Variables ¶
This section is empty.
Functions ¶
func ReadFileStreamToList ¶
ReadFileStreamToList
@Description: 读取文件流 @param r 文件流 @param sheetIndex 需要读取第几个单元薄 @param ptr 读取后的切片对象 @return resultData 返回的切片 @return err 错误信息
func ReadFileToList ¶
ReadFileToList
@Description:读取本地文件至切片 @param filePath 本地文件的路径 @param sheetIndex 需要读取第几个单元薄 @return resultData 返回的切片 @return err 错误信息
Types ¶
type ExcelFields ¶
type ExcelFields struct {
Title string //名称
Index int //索引,从0开始
Format string //所以的格式化类型(datetime),没有标注的话,默认是属性的类型
Name string //json字段名称
FieldType string //字段类型
Tags map[string]string //保存所有tags
}
ExcelFields /**Excel的字段属性
type ExcelStruct ¶
type ExcelStruct struct {
MapIndex map[int]string //按照index排序的map
IndexMax int //列index最大值
Fields map[string]ExcelFields //所有字段
StartRow int //第几行开始为具体数据
Err error //错误
ConvertTypeErr bool //类型转换时候,产生错误时是否直接提示报错
}
ExcelStruct /** 封装对象
func NewExcelStruct ¶
func NewExcelStruct(StartRow, IndexMax int, fastErr bool) *ExcelStruct
NewExcelStruct
@Description: @param StartRow 开始行,索引从0开始 @param IndexMax 索引最大行,如果结构体中的index大于配置的,那么使用结构体中的 @param fastErr @return *ExcelStruct
func NewExcelStructDefault ¶
func NewExcelStructDefault() *ExcelStruct
NewExcelStructDefault
@Description: 创建读取的结构体 默认,从第一行开始,索引从 0开始 @return *ExcelStruct
func (*ExcelStruct) Row ¶
func (c *ExcelStruct) Row(row []string) (map[string]interface{}, error)
Row /** 处理一行的数据,将行数据根据index转换成map
func (*ExcelStruct) RowsAllProcess ¶
func (c *ExcelStruct) RowsAllProcess(rows [][]string, callback Callback) error
RowsAllProcess /** 处理sheet的rows
func (*ExcelStruct) RowsProcess ¶
func (c *ExcelStruct) RowsProcess(rows [][]string, callback Callback) error
RowsProcess /** 处理函数
func (*ExcelStruct) SetPointerStruct ¶
func (c *ExcelStruct) SetPointerStruct(ptr interface{}) *ExcelStruct
SetPointerStruct /** 设置并构造转换的结构体
type FieldsModel ¶
Click to show internal directories.
Click to hide internal directories.