Documentation
¶
Index ¶
- Constants
- Variables
- func ExportToJSON(excelDir string, opts ...Option) (err error)
- type Direction
- type Field
- type FieldType
- type Option
- func WithGoStructExport(outPath string, packageName string, opts ...SchemaOption) Option
- func WithJson(outPath string, opts ...SchemaOption) Option
- func WithSchemaExport(outPath string, schemaType SchemaType, opts ...SchemaOption) Option
- func WithTsInterfaceExport(outPath string, opts ...SchemaOption) Option
- type SchemaOption
- type SchemaType
- type Sheet
- type ShouldExportField
Constants ¶
View Source
const ( SchemaTypeTsInterface = "tsInterface" SchemaTypeGoStruct = "goStruct" )
View Source
const ( FieldTypeString FieldType = "string" FieldTypeInt = "int64" FieldTypeFloat = "float64" FieldTypeArray = "array" FieldTypeObjectArray = "objectArray" )
View Source
const FieldNameLine = 3
View Source
const FieldTypeLine = 2
View Source
const FieldVisibleLine = 1
Variables ¶
View Source
var ErrEmptySheet = errors.New("empty sheet")
View Source
var ShouldExportAllField = func(_ *Field) bool { return true }
Functions ¶
func ExportToJSON ¶
ExportToJSON 是一个将数据导出为 JSON 格式的函数。 ExportToJSON is a function that exports data to JSON format.
Types ¶
type Direction ¶
type Direction string
const ( DirectionHorizontal Direction = "h" DirectionVertical = "v" )
type Field ¶
type Field struct {
OrdinalName string
Name string
Type FieldType
Index int
Rang [2]int
SubFields []*Field
Mark string
}
func ParseField ¶
type Option ¶
type Option func(*config)
func WithGoStructExport ¶
func WithGoStructExport(outPath string, packageName string, opts ...SchemaOption) Option
WithGoStructExport is a function that configures Go struct export settings. WithGoStructExport 是一个配置 Go 结构体导出设置的函数。
func WithJson ¶
func WithJson(outPath string, opts ...SchemaOption) Option
WithJson is a function that configures JSON export settings. WithJson 是一个配置 JSON 导出设置的函数。 outPath: 输出路径 hashKey: 是否以 Hash 导出
func WithSchemaExport ¶
func WithSchemaExport(outPath string, schemaType SchemaType, opts ...SchemaOption) Option
WithSchemaExport is a function that configures schema export settings. WithSchemaExport 是一个配置模式导出设置的函数。
func WithTsInterfaceExport ¶
func WithTsInterfaceExport(outPath string, opts ...SchemaOption) Option
WithTsInterfaceExport is a function that configures TypeScript interface export settings. WithTsInterfaceExport 是一个配置 TypeScript 接口导出设置的函数。
type SchemaOption ¶
type SchemaOption func(*schema)
func WithExtraArgs ¶
func WithExtraArgs(args []string) SchemaOption
func WithGoIntType ¶
func WithGoIntType(goIntType string) SchemaOption
func WithHashKey ¶
func WithHashKey(hashKey string, hashTolerance ...bool) SchemaOption
func WithShouldExportField ¶
func WithShouldExportField(shouldExportField ShouldExportField) SchemaOption
type SchemaType ¶
type SchemaType string
type Sheet ¶
type Sheet struct {
FileName string
Name string
Fields []*Field
Rows [][]string
Direction Direction
}
func (*Sheet) ReadRowData ¶
type ShouldExportField ¶
Click to show internal directories.
Click to hide internal directories.