helper

package
v0.0.0-...-a7dee75 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvGBKToUTF8

func ConvGBKToUTF8(s []byte) ([]byte, error)

func ConvUTF8ToGBK

func ConvUTF8ToGBK(s []byte) ([]byte, error)

func GetSheetValueString

func GetSheetValueString(sheet *xlsx.Sheet, row, col int) string

func IsFullRowEmpty

func IsFullRowEmpty(sheet *xlsx.Sheet, row int) bool

整行都是空的

func ReadSheetRow

func ReadSheetRow(sheet TableSheet, row int) (ret []string)

func WriteFile

func WriteFile(filename string, data []byte) error

func WriteIndexTableHeader

func WriteIndexTableHeader(sheet TableSheet)

func WriteRowValues

func WriteRowValues(sheet TableSheet, valueList ...string)

func WriteTypeTableHeader

func WriteTypeTableHeader(sheet TableSheet)

Types

type CSVFile

type CSVFile struct {
	Name string
	// contains filtered or unexported fields
}

func NewCSVFile

func NewCSVFile() *CSVFile

func (*CSVFile) Load

func (self *CSVFile) Load(fileName string) error

func (*CSVFile) MaxCol

func (self *CSVFile) MaxCol() int

func (*CSVFile) Save

func (self *CSVFile) Save(filename string) error

func (*CSVFile) Sheets

func (self *CSVFile) Sheets() (ret []TableSheet)

func (*CSVFile) Transform

func (self *CSVFile) Transform(convf func(s []byte) ([]byte, error))

type CSVSheet

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

func (*CSVSheet) GetValue

func (self *CSVSheet) GetValue(row, col int, opt *ValueOption) string

func (*CSVSheet) IsRowEmpty

func (self *CSVSheet) IsRowEmpty(row, maxCol int) bool

func (*CSVSheet) MaxColumn

func (self *CSVSheet) MaxColumn() int

func (*CSVSheet) Name

func (self *CSVSheet) Name() string

func (*CSVSheet) SetValue

func (self *CSVSheet) SetValue(row, col int, value string) bool

func (*CSVSheet) WriteRow

func (self *CSVSheet) WriteRow(valueList ...string)

type FileGetter

type FileGetter interface {
	GetFile(filename string) (TableFile, error)
}

type FileLoader

type FileLoader struct {
	UseGBKCSV bool
	// contains filtered or unexported fields
}

func NewFileLoader

func NewFileLoader(syncLoad bool, cacheDir string) *FileLoader

func (*FileLoader) AddFile

func (self *FileLoader) AddFile(filename string)

func (*FileLoader) Commit

func (self *FileLoader) Commit()

func (*FileLoader) GetFile

func (self *FileLoader) GetFile(filename string) (TableFile, error)

type MemFile

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

func NewMemFile

func NewMemFile() *MemFile

func (*MemFile) AddFile

func (self *MemFile) AddFile(filename string, file TableFile) (ret *MemFileData)

func (*MemFile) CreateCSVFile

func (self *MemFile) CreateCSVFile(filename string) TableSheet

func (*MemFile) CreateXLSXFile

func (self *MemFile) CreateXLSXFile(filename string) TableSheet

func (*MemFile) GetFile

func (self *MemFile) GetFile(filename string) (TableFile, error)

func (*MemFile) VisitAllTable

func (self *MemFile) VisitAllTable(callback func(data *MemFileData) bool)

type MemFileData

type MemFileData struct {
	File      TableFile
	TableName string
	FileName  string
}

type TableFile

type TableFile interface {
	Load(filename string) error

	// 保存到文件
	Save(filename string) error

	// 获取所有表单
	Sheets() []TableSheet
}

func ConvertToCSV

func ConvertToCSV(inputFile TableFile) (outputFile TableFile)

func NewXlsxFile

func NewXlsxFile(cacheDir string) TableFile

type TableSheet

type TableSheet interface {

	// 表单名称
	Name() string

	// 从表单指定单元格获取值
	GetValue(row, col int, opt *ValueOption) string

	// 最大列
	MaxColumn() int

	// 写入一行数据
	WriteRow(valueList ...string)

	// 检测本行是否全空(结束)
	IsRowEmpty(row, maxCol int) bool
}

type ValueOption

type ValueOption struct {
	ValueAsFloat bool
}

type XlsxFile

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

func (*XlsxFile) FromXFile

func (self *XlsxFile) FromXFile(file *xlsx.File)

func (*XlsxFile) Load

func (self *XlsxFile) Load(filename string) (err error)

func (*XlsxFile) Save

func (self *XlsxFile) Save(filename string) error

func (*XlsxFile) Sheets

func (self *XlsxFile) Sheets() (ret []TableSheet)

type XlsxSheet

type XlsxSheet struct {
	*xlsx.Sheet
}

func (*XlsxSheet) GetValue

func (self *XlsxSheet) GetValue(row, col int, opt *ValueOption) (ret string)

func (*XlsxSheet) IsRowEmpty

func (self *XlsxSheet) IsRowEmpty(row, maxCol int) bool

func (*XlsxSheet) MaxColumn

func (self *XlsxSheet) MaxColumn() int

func (*XlsxSheet) Name

func (self *XlsxSheet) Name() string

func (*XlsxSheet) WriteRow

func (self *XlsxSheet) WriteRow(valueList ...string)

Jump to

Keyboard shortcuts

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