xlsx

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Overview

Package xlsx 主要实现了stream/file的接口

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInStream

func NewInStream(filename string) (file.InStream, error)

NewInStream 创建一个名为filename的xlsx输入流

func NewOutStream

func NewOutStream(filename string) (file.OutStream, error)

NewOutStream 创建一个名为filename的xlsx输出流

func NewWriter

func NewWriter(f *excelize.File, c *config.JSON) (file.StreamWriter, error)

NewWriter 通过文件句柄f,和配置文件c 创建xlsx流写入器

Types

type Column

type Column struct {
	Index  string `json:"index"`  //列索引,A,B,C....AA.....
	Type   string `json:"type"`   //类型 类型 bool bigInt decimal string time
	Format string `json:"format"` //joda时间格式
	// contains filtered or unexported fields
}

Column 列信息

type Creator

type Creator struct {
}

Creator xlsx输出流创建器

func (*Creator) Create

func (c *Creator) Create(filename string) (file.OutStream, error)

Create 创建一个名为filename的xlsx输出流

type InConfig

type InConfig struct {
	Columns    []Column `json:"column"`     //列信息数组
	Sheet      string   `json:"sheet"`      //表格名
	NullFormat string   `json:"nullFormat"` //null文本
	StartRow   int      `json:"startRow"`   //开始读取行数,从第1行开始
}

InConfig 输入xlsx配置

func NewInConfig

func NewInConfig(conf *config.JSON) (c *InConfig, err error)

NewInConfig 新建以json配置conf的输入xlsx配置

type Opener

type Opener struct {
}

Opener xlsx输入流打开器

func (*Opener) Open

func (o *Opener) Open(filename string) (file.InStream, error)

Open 打开一个名为filename的xlsx输入流

type OutConfig

type OutConfig struct {
	Columns    []Column `json:"column"`     //列信息数组
	Sheets     []string `json:"sheets"`     //表格名
	NullFormat string   `json:"nullFormat"` //null文本
	HasHeader  bool     `json:"hasHeader"`  // 是否有列头
	Header     []string `json:"header"`     // 列头
	SheetRow   int      `json:"sheetRow"`   // sheet最大的行数
}

OutConfig 输出xlsx配置

func NewOutConfig

func NewOutConfig(conf *config.JSON) (c *OutConfig, err error)

NewOutConfig 新建以json配置conf的输出xlsx配置

type Rows

type Rows struct {
	*excelize.Rows
	// contains filtered or unexported fields
}

Rows 行读取器

func NewRows

func NewRows(f *excelize.File, c *config.JSON) (rows *Rows, err error)

NewRows 通过文件句柄f,和配置文件c 创建行读取器

func (*Rows) Scan

func (r *Rows) Scan() (columns []element.Column, err error)

Scan 扫描成列

type Stream

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

Stream xlsx文件流

func (*Stream) Close

func (s *Stream) Close() (err error)

Close 关闭文件流

func (*Stream) Rows

func (s *Stream) Rows(conf *config.JSON) (file.Rows, error)

Rows 新建一个配置未conf的csv行读取器

func (*Stream) Writer

func (s *Stream) Writer(conf *config.JSON) (file.StreamWriter, error)

Writer 新建一个配置未conf的xlsx流写入器

type Writer

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

Writer xlsx流写入器

func (*Writer) Close

func (w *Writer) Close() (err error)

Close w.writer有可能为空,刷新文件内存到临时文件

func (*Writer) Flush

func (w *Writer) Flush() (err error)

Flush 不刷新

func (*Writer) Write

func (w *Writer) Write(record element.Record) (err error)

Write 将记录record 写入xlsx文件

Jump to

Keyboard shortcuts

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