l_excel_export/option.go

48 lines
968 B
Go

package excel_export
import "github.com/xuri/excelize/v2"
type (
Option func(export *ExportExcel)
FiledMapping struct {
FieldName string `json:"filed_name"` //原字段
ColName string `json:"col_name"` //excel列名
}
)
// WithPassword excel打开密码
func WithPassword(password string) Option {
return func(s *ExportExcel) {
s.password = password
}
}
// WithSaveFunc 抛出file文件交由外部处理
func WithSaveFunc(saveFunc func(file *excelize.File) (url string, err error)) Option {
return func(s *ExportExcel) {
s.saveFunc = saveFunc
}
}
// WithSheet excel的sheet名称
func WithSheet(sheetName string) Option {
return func(s *ExportExcel) {
s.sheetName = sheetName
}
}
// WithLogPath 日志保存文件
func WithLogPath(logPath string) Option {
return func(s *ExportExcel) {
s.logPath = logPath
}
}
// WithJobName 任务名称
func WithJobName(name string) Option {
return func(s *ExportExcel) {
s.jobName = name
}
}