goxlsx

package
v1.2.151 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

go xlxs

基于这个库封装
go get github.com/xuri/excelize/v2

  • 目前只支持写一个sheet

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UTF8    = unicode.UTF8
	UTF8BOM = unicode.UTF8BOM
	GBK     = simplifiedchinese.GBK
	//UTF16 有很多种 参考 unicode包
	UTF16 = unicode.UTF16(unicode.LittleEndian, unicode.ExpectBOM)
)

常用文件编码 unicode.UTF8, unicode.UTF16(BigEndian, UseBOM), unicode.UTF16(BigEndian, IgnoreBOM), unicode.UTF16(LittleEndian, IgnoreBOM), 常用文件编码需要用

Functions

This section is empty.

Types

type CsvReader added in v1.2.131

type CsvReader struct {
	FilePath string
	Comma    rune //csv 列分割符
	// contains filtered or unexported fields
}

func NewCsvReader added in v1.2.125

func NewCsvReader(csvFile string, comma rune) (*CsvReader, error)

comma 默认传 ','

func (*CsvReader) ReadAll added in v1.2.131

func (c *CsvReader) ReadAll(encoding encoding.Encoding) ([][]string, error)

func (*CsvReader) ReadAllJson added in v1.2.131

func (c *CsvReader) ReadAllJson(encoding encoding.Encoding) ([]map[string]string, error)

第一行作为字段名称,后续行数据转换为json数据一次性返回所有数据

func (*CsvReader) ReadGBKAll added in v1.2.131

func (c *CsvReader) ReadGBKAll() ([][]string, error)

func (*CsvReader) ReadGBKLine added in v1.2.131

func (c *CsvReader) ReadGBKLine(lineDataFunc func(record []string) error) error

func (*CsvReader) ReadLine added in v1.2.131

func (c *CsvReader) ReadLine(encoding encoding.Encoding, lineDataFunc func(record []string) error) error

func (*CsvReader) ReadLineJson added in v1.2.131

func (c *CsvReader) ReadLineJson(encoding encoding.Encoding, lineDataFunc func(record map[string]string) error) error

第一行作为字段名称,后续行数据转换为json数据,一行回调一个json数据

func (*CsvReader) ReadUTF16All added in v1.2.131

func (c *CsvReader) ReadUTF16All() ([][]string, error)

func (*CsvReader) ReadUTF16Line added in v1.2.131

func (c *CsvReader) ReadUTF16Line(lineDataFunc func(record []string) error) error

func (*CsvReader) ReadUTF8All added in v1.2.131

func (c *CsvReader) ReadUTF8All() ([][]string, error)

func (*CsvReader) ReadUTF8Line added in v1.2.131

func (c *CsvReader) ReadUTF8Line(lineDataFunc func(record []string) error) error

type CsvWriter added in v1.2.141

type CsvWriter struct {
	FilePath string
	Comma    rune //csv 列分割符
	// contains filtered or unexported fields
}

type XlsxRead added in v1.2.122

type XlsxRead struct {
	FilePath string
}

需要扩展按行读取文件

func NewReader added in v1.2.125

func NewReader(xlsxFile string) (*XlsxRead, error)

func (*XlsxRead) Read added in v1.2.142

func (r *XlsxRead) Read(fn func(n int, row []string) error) error

func (*XlsxRead) ReadBySheet added in v1.2.142

func (r *XlsxRead) ReadBySheet(sheet string, fn func(n int, row []string) error) error

func (*XlsxRead) ReadFile added in v1.2.142

func (r *XlsxRead) ReadFile(file string, fn func(n int, row []string) error) error

type XlsxWrite added in v1.2.116

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

扩展需要append to file 功能

func NewWriter added in v1.2.125

func NewWriter() *XlsxWrite

func (*XlsxWrite) AppendData added in v1.2.116

func (x *XlsxWrite) AppendData(data []interface{}) *XlsxWrite

func (*XlsxWrite) AppendRows added in v1.2.116

func (x *XlsxWrite) AppendRows(data [][]interface{}) *XlsxWrite

func (*XlsxWrite) Output added in v1.2.116

func (x *XlsxWrite) Output(w http.ResponseWriter, filename string) (err error)

func (*XlsxWrite) OutputForGin added in v1.2.117

func (x *XlsxWrite) OutputForGin(ctx *gin.Context, filename string) (err error)

func (*XlsxWrite) Save2File added in v1.2.116

func (x *XlsxWrite) Save2File(filename string) (err error)

func (*XlsxWrite) SetSheetName added in v1.2.116

func (x *XlsxWrite) SetSheetName(sheetName string) *XlsxWrite

func (*XlsxWrite) SetTitles added in v1.2.116

func (x *XlsxWrite) SetTitles(titles []string) *XlsxWrite

Jump to

Keyboard shortcuts

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