gexcel

package
v0.0.0-...-3e86cb5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2022 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GExcel

type GExcel struct {
	FileName  string
	SheetName string
	Header    []string
	Data      [][]string
}

GExcel TODO 自定义Excel

func (GExcel) OpenAsColumn2Map

func (xlsx GExcel) OpenAsColumn2Map() []map[string]string

OpenAsColumn2Map TODO 打开Excel,需要先执行Save的demo保存一波

rr := gexcel.GExcel{
	FileName:  "test.xlsx",
	SheetName: "Sheet1",
}.OpenAsColumn2Map()

bt, _ := json.Marshal(rr)
fmt.Println(string(bt))

func (GExcel) OpenAsColumn2Slice

func (xlsx GExcel) OpenAsColumn2Slice() [][]string

OpenAsColumn2Slice TODO 打开Excel

func (GExcel) Save

func (xlsx GExcel) Save()

Save TODO 保存Excel

header := []string{}
data := [][]string{}
rowData := []string{}
for i := 1; i < 10; i++ {
	header = append(header, fmt.Sprintf("第 %d 列", i))
	rowData = append(rowData, fmt.Sprintf("col value %d", i))
}

for i := 1; i < 10; i++ {
	data = append(data, rowData)
}

xlsx := gexcel.GExcel{
	FileName:  "test.xlsx",
	SheetName: "Sheet1",
	Header:    header,
	Data:      data,
}
xlsx.Save()

Jump to

Keyboard shortcuts

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