excelexport

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 6 Imported by: 0

README

excelexport

Excel Export

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetCellValueSimple = func(key string, data map[string]interface{}) interface{} {
	v, ok := data[key]
	if !ok {
		return key
	}
	return v
}

simple return the value by key, if not existed, return the empty

Functions

This section is empty.

Types

type ExcelExport

type ExcelExport struct {
	SheetName string
	Index     bool //similar to pandas export setting if included Index.
	Columns   []*ExcelHeader
	Style     *excelize.Style
	Logger    *zap.Logger
	Mode      GetCellValue
}

func (*ExcelExport) Export

func (ee *ExcelExport) Export(f *excelize.File, data []map[string]interface{}) error

type ExcelHeader

type ExcelHeader struct {
	Title string
	Width float64
	Key   string //key for
	// contains filtered or unexported fields
}

type ExportDefine

type ExportDefine struct {
	Query  *query.RawQuery
	Output *ExcelExport
}

type ExportService

type ExportService struct {
	Logger  *zap.Logger
	DB      *gorm.DB
	Exports []*ExportDefine
}

func (*ExportService) DoExport

func (es *ExportService) DoExport(params map[string]interface{}, w io.Writer) error

func (*ExportService) Init

func (es *ExportService) Init()

type GetCellValue

type GetCellValue func(key string, data map[string]interface{}) interface{}

func for how to get Value from the key defined.

type Sheet

type Sheet struct {
	File    *excelize.File
	StyleID int
	Name    string
	Row     int
	Col     int
}

func (*Sheet) GetAxis

func (s *Sheet) GetAxis() string

func (*Sheet) NextCell

func (s *Sheet) NextCell()

func (*Sheet) NextRow

func (s *Sheet) NextRow()

func (*Sheet) SetFloat

func (s *Sheet) SetFloat(value float64, prec, bitSize int)

func (*Sheet) SetHeader

func (s *Sheet) SetHeader(header *ExcelHeader)

func (*Sheet) SetInt

func (s *Sheet) SetInt(value int, style ...int)

func (*Sheet) SetString

func (s *Sheet) SetString(value string)

func (*Sheet) SetValue

func (s *Sheet) SetValue(value interface{})

Jump to

Keyboard shortcuts

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