xls2json

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = &Options{
	StartRow:       0,
	HandleEmptyRow: 0,
}
View Source
var DefaultSheetName = "Sheet1"

Functions

This section is empty.

Types

type Options

type Options struct {
	// 从表格的第几行开始,默认0,即第一行
	StartRow int
	// 自定义表头,对应json中的key,默认为空取表格的第一行
	CustomHeaders []string
	// 跳过表格的第多少行,从0开始
	SkipRows []int
	// 只解析表格中最多多少行,默认无上限
	MaxRows int
	// 遇到多少个空行怎么处理
	HandleEmptyRow int //0-默认写入空行,1-skip跳过空行,2-退出

}

type SheetResult

type SheetResult struct {
	SheetName string
	RawBytes  []byte
	Rows      int
	CostTime  time.Duration
	SheetJson sheetJSONMap
}

func ConvertFirstSheet

func ConvertFirstSheet(xlsxPath string, options *Options) (*SheetResult, error)

Convert first excel sheet to json

func ConvertOneSheet

func ConvertOneSheet(xlsxPath string, sheetName string, options *Options) (*SheetResult, error)

Convert specified one excel sheet to json

func (*SheetResult) OnlyJson

func (sr *SheetResult) OnlyJson() string

func (*SheetResult) Summary

func (sr *SheetResult) Summary() string

type TotalResult

type TotalResult struct {
	SheetResults map[string]*SheetResult //key为sheetName
	Bytes        []byte
}

/////////////////

func ConvertAllSheets

func ConvertAllSheets(xlsxPath string, options *Options) (*TotalResult, error)

Convert all excel sheets to json

func (*TotalResult) OnlyJson

func (tr *TotalResult) OnlyJson() string

func (*TotalResult) OnlyJsonBytes

func (tr *TotalResult) OnlyJsonBytes() []byte

func (*TotalResult) Summary

func (tr *TotalResult) Summary() string

Jump to

Keyboard shortcuts

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