excel

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

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

func ExportToJSON(excelDir string, opts ...Option) (err error)

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

func ParseField(index int, name string) *Field

func (*Field) ReadValue

func (f *Field) ReadValue(row []string, index int, shouldFieldDisplay func(f *Field) bool) (value any, err error)

type FieldType

type FieldType string

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

func (s *Sheet) ReadRowData(i int, shouldFieldDisplay func(f *Field) bool) (item map[string]any, err error)

func (*Sheet) ToJson

func (s *Sheet) ToJson(fieldsFilter func(f *Field) bool) (data []map[string]any, err error)

type ShouldExportField

type ShouldExportField func(*Field) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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