xlsx

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 12 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.

README

xlsx

wrapper for simple xlsx generation

Build Status Coverage Status Go Report Card Documentation

Install

$ go get github.com/lovego/xlsx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(sheets ...Sheet) (*xlsx.File, error)

func GetValue

func GetValue(value reflect.Value, names []string) (interface{}, bool)

func SetGetters

func SetGetters(columns []Column, getters map[string]func(row interface{}) interface{})

func Write

func Write(w io.Writer, sheets ...Sheet) error

func WriteFile

func WriteFile(path string, sheets ...Sheet) error

func WriteHttp

func WriteHttp(rw http.ResponseWriter, name string, sheets ...Sheet) error

Types

type Column

type Column struct {
	Label  string                            `json:"label" c:"标签(显示名称)"`
	Prop   string                            `json:"prop"  c:"属性(字段名称)"`
	Width  float64                           `json:"width" c:"宽度"`
	Getter func(row interface{}) interface{} `json:"-"`
	// contains filtered or unexported fields
}

func (*Column) GetValue

func (c *Column) GetValue(row reflect.Value) (interface{}, bool)

type Sheet

type Sheet struct {
	Name    string
	Data    interface{}
	Columns []Column
}

func (*Sheet) Generate

func (s *Sheet) Generate(file *xlsx.File) error

func (*Sheet) GenerateBody added in v0.0.9

func (s *Sheet) GenerateBody(sheet *xlsx.Sheet) error

func (*Sheet) GenerateHeader added in v0.0.9

func (s *Sheet) GenerateHeader(sheet *xlsx.Sheet)

Jump to

Keyboard shortcuts

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