excelx

package
v1.11.6 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Key      string   // 字段唯一标识(供机器读写精准对齐,如 field_uid)
	Title    string   // 字段中文展示名称(供人类阅读,如 field_name)
	Type     string   // 数据类型:string / int / float / number / bool / select / list / datetime
	Required bool     // 是否必填约束
	Unique   bool     // 是否唯一约束(如资产名称 name)
	Secure   bool     // 是否敏感加密标记
	Options  []string // 预设合法枚举选项(select/list 类型生成下拉验证与值域校验)
	Hidden   bool     // 是否跳过导出(如 file 类型附件不参与 Excel 交换)
}

Column 声明式列 Schema 定义 驱动表格模板生成、数据导出渲染与导入校验反序列化,一次声明,导入导出共享

func (Column) ConstraintText

func (c Column) ConstraintText() string

ConstraintText 生成规范的约束描述文本,用于写入第三行约束指引表头

func (Column) IsVisible

func (c Column) IsVisible() bool

IsVisible 判断是否应当参与导出(Hidden 类型如 file 附件跳过)

func (Column) NeedsValidation

func (c Column) NeedsValidation() bool

NeedsValidation 判断当前列是否需要挂载下拉框数据验证

type StyleSet

type StyleSet struct {
	// 三层表头:业务主标题 / 技术 Key / 填写约束指引
	TitleRow      int
	KeyRow        int
	ConstraintRow int
	// 数据行:斑马纹奇偶行交替
	OddRow  int
	EvenRow int
}

StyleSet 现代 SaaS 风格 Excel 样式集

type TableReader

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

TableReader 声明式 Excel 反序列化与校验引擎

func NewReader

func NewReader(columns []Column) *TableReader

NewReader 实例化读取器,自动过滤 Hidden 列

func (*TableReader) Read

func (r *TableReader) Read(fileData []byte) ([]map[string]interface{}, error)

Read 从 Excel 二进制流中按三层表头契约解析数据行,返回强类型校验后的记录集

type TableWriter

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

TableWriter 声明式 Excel 表格生成器

func NewWriter

func NewWriter(sheetName string, columns []Column) *TableWriter

NewWriter 实例化表格生成器,自动过滤 Hidden 列(如 file 附件类型)

func (*TableWriter) WriteData

func (w *TableWriter) WriteData(records []map[string]interface{}) ([]byte, error)

WriteData 生成包含三层表头、数据记录与下拉验证的完整 Excel 字节流

func (*TableWriter) WriteTemplate

func (w *TableWriter) WriteTemplate() ([]byte, error)

WriteTemplate 生成包含三层表头、100 行格式化录入区与下拉验证的空白导入模板

Jump to

Keyboard shortcuts

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