excel

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnNumberToText

func ColumnNumberToText(columnNumber int) (string, error)

ColumnNumberToText 列索引转文字

func ColumnTextToNumber

func ColumnTextToNumber(columnText string) int

ColumnTextToNumber 列文字转索引

func ReadDemo

func ReadDemo(filename string)

func WriteDemo

func WriteDemo(filename string)

Types

type Cell

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

Cell Excel单元格

func NewCellAny

func NewCellAny(content any) *Cell

NewCellAny 实例化:任意值

func NewCellBool

func NewCellBool(content any) *Cell

NewCellBool 实例化:布尔

func NewCellFloat64

func NewCellFloat64(content any) *Cell

NewCellFloat64 实例化:浮点

func NewCellFormula

func NewCellFormula(content string) *Cell

NewCellFormula 实例化:公式

func NewCellInt

func NewCellInt(content any) *Cell

NewCellInt 实例化:整数

func NewCellTime

func NewCellTime(content time.Time) *Cell

NewCellTime 实例化:时间

func (*Cell) GetBorder

func (my *Cell) GetBorder() *array.AnyArray[border]

GetBorder 获取边框

func (*Cell) GetContent

func (my *Cell) GetContent() any

GetContent 获取内容

func (*Cell) GetContentType

func (my *Cell) GetContentType() CellContentType

GetContentType 获取单元格类型

func (*Cell) GetCoordinate

func (my *Cell) GetCoordinate() string

GetCoordinate 获取单元格坐标

func (*Cell) GetFontBold

func (my *Cell) GetFontBold() bool

GetFontBold 获取字体粗体

func (*Cell) GetFontFamily

func (my *Cell) GetFontFamily() string

GetFontFamily 获取字体

func (*Cell) GetFontItalic

func (my *Cell) GetFontItalic() bool

GetFontItalic 获取字体斜体

func (*Cell) GetFontRgb

func (my *Cell) GetFontRgb() string

GetFontRgb 获取字体颜色

func (*Cell) GetFontSize

func (my *Cell) GetFontSize() float64

GetFontSize 获取字体字号

func (*Cell) GetPatternRgb

func (my *Cell) GetPatternRgb() string

GetPatternRgb 获取填充色

func (*Cell) GetWrapText

func (my *Cell) GetWrapText() bool

GetWrapText 获取自动换行

func (*Cell) Init

func (my *Cell) Init(content any) *Cell

Init 初始化

func (*Cell) SetBorderBottomRbgFunc

func (my *Cell) SetBorderBottomRbgFunc(condition func() (string, bool)) *Cell

SetBorderBottomRbgFunc 设置边框颜色:下 函数

func (*Cell) SetBorderBottomRgb

func (my *Cell) SetBorderBottomRgb(borderBottomRgb string, condition bool) *Cell

SetBorderBottomRgb 设置边框颜色:下

func (*Cell) SetBorderBottomStyle

func (my *Cell) SetBorderBottomStyle(borderBottomStyle int, condition bool) *Cell

SetBorderBottomStyle 设置边框样式:下

func (*Cell) SetBorderBottomStyleFunc

func (my *Cell) SetBorderBottomStyleFunc(condition func() (int, bool)) *Cell

SetBorderBottomStyleFunc 设置边框样式:下 函数

func (*Cell) SetBorderDiagonalDownRbgFunc

func (my *Cell) SetBorderDiagonalDownRbgFunc(condition func() (string, bool)) *Cell

SetBorderDiagonalDownRbgFunc 设置边框颜色:对角线下 函数

func (*Cell) SetBorderDiagonalDownRgb

func (my *Cell) SetBorderDiagonalDownRgb(borderDiagonalDownRgb string, condition bool) *Cell

SetBorderDiagonalDownRgb 设置边框颜色:对角线下

func (*Cell) SetBorderDiagonalDownStyle

func (my *Cell) SetBorderDiagonalDownStyle(borderDiagonalDownStyle int, condition bool) *Cell

SetBorderDiagonalDownStyle 设置边框样式:对角线下

func (*Cell) SetBorderDiagonalDownStyleFunc

func (my *Cell) SetBorderDiagonalDownStyleFunc(condition func() (int, bool)) *Cell

SetBorderDiagonalDownStyleFunc 设置边框样式:对角线下 函数

func (*Cell) SetBorderDiagonalUpRbgFunc

func (my *Cell) SetBorderDiagonalUpRbgFunc(condition func() (string, bool)) *Cell

SetBorderDiagonalUpRbgFunc 设置边框颜色:对角线上 函数

func (*Cell) SetBorderDiagonalUpRgb

func (my *Cell) SetBorderDiagonalUpRgb(borderDiagonalUpRgb string, condition bool) *Cell

SetBorderDiagonalUpRgb 设置边框颜色:对角线上

func (*Cell) SetBorderDiagonalUpStyle

func (my *Cell) SetBorderDiagonalUpStyle(borderDiagonalUpStyle int, condition bool) *Cell

SetBorderDiagonalUpStyle 设置边框样式:对角线上

func (*Cell) SetBorderDiagonalUpStyleFunc

func (my *Cell) SetBorderDiagonalUpStyleFunc(condition func() (int, bool)) *Cell

SetBorderDiagonalUpStyleFunc 设置边框样式:对角线上 函数

func (*Cell) SetBorderLeftRbgFunc

func (my *Cell) SetBorderLeftRbgFunc(condition func() (string, bool)) *Cell

SetBorderLeftRbgFunc 设置边框颜色:左 函数

func (*Cell) SetBorderLeftRgb

func (my *Cell) SetBorderLeftRgb(borderLeftRgb string, condition bool) *Cell

SetBorderLeftRgb 设置边框颜色:左

func (*Cell) SetBorderLeftStyle

func (my *Cell) SetBorderLeftStyle(borderLeftStyle int, condition bool) *Cell

SetBorderLeftStyle 设置边框样式:左

func (*Cell) SetBorderLeftStyleFunc

func (my *Cell) SetBorderLeftStyleFunc(condition func() (int, bool)) *Cell

SetBorderLeftStyleFunc 设置边框样式:左 函数

func (*Cell) SetBorderRightRbgFunc

func (my *Cell) SetBorderRightRbgFunc(condition func() (string, bool)) *Cell

SetBorderRightRbgFunc 设置边框颜色:右 函数

func (*Cell) SetBorderRightRgb

func (my *Cell) SetBorderRightRgb(borderRightRgb string, condition bool) *Cell

SetBorderRightRgb 设置边框颜色:右

func (*Cell) SetBorderRightStyle

func (my *Cell) SetBorderRightStyle(borderRightStyle int, condition bool) *Cell

SetBorderRightStyle 设置边框样式:右

func (*Cell) SetBorderRightStyleFunc

func (my *Cell) SetBorderRightStyleFunc(condition func() (int, bool)) *Cell

SetBorderRightStyleFunc 设置边框样式:右 函数

func (*Cell) SetBorderSurrounding

func (my *Cell) SetBorderSurrounding(borderRgb string, borderStyle int, condition bool) *Cell

SetBorderSurrounding 设置四周边框

func (*Cell) SetBorderSurroundingFunc

func (my *Cell) SetBorderSurroundingFunc(condition func() (string, int, bool)) *Cell

SetBorderSurroundingFunc 设置四周边框 函数

func (*Cell) SetBorderTopRbgFunc

func (my *Cell) SetBorderTopRbgFunc(condition func() (string, bool)) *Cell

SetBorderTopRbgFunc 设置边框颜色:上 函数

func (*Cell) SetBorderTopRgb

func (my *Cell) SetBorderTopRgb(borderTopRgb string, condition bool) *Cell

SetBorderTopRgb 设置边框颜色:上

func (*Cell) SetBorderTopStyle

func (my *Cell) SetBorderTopStyle(borderTopStyle int, condition bool) *Cell

SetBorderTopStyle 设置边框样式:上

func (*Cell) SetBorderTopStyleFunc

func (my *Cell) SetBorderTopStyleFunc(condition func() (int, bool)) *Cell

SetBorderTopStyleFunc 设置边框样式:上 函数

func (*Cell) SetContent

func (my *Cell) SetContent(content any) *Cell

SetContent 设置内容

func (*Cell) SetContentType

func (my *Cell) SetContentType(contentType CellContentType) *Cell

SetContentType 设置单元格类型

func (*Cell) SetCoordinate

func (my *Cell) SetCoordinate(coordinate string) *Cell

SetCoordinate 设置单元格坐标

func (*Cell) SetFontBold

func (my *Cell) SetFontBold(fontBold bool, condition bool) *Cell

SetFontBold 设置字体粗体

func (*Cell) SetFontBoldFunc

func (my *Cell) SetFontBoldFunc(condition func() (bool, bool)) *Cell

SetFontBoldFunc 设置字体粗体:函数

func (*Cell) SetFontFamily

func (my *Cell) SetFontFamily(fontFamily string, condition bool) *Cell

SetFontFamily 设置字体

func (*Cell) SetFontFamilyFunc

func (my *Cell) SetFontFamilyFunc(condition func() (string, bool)) *Cell

SetFontFamilyFunc 设置字体:函数

func (*Cell) SetFontItalic

func (my *Cell) SetFontItalic(fontItalic bool, condition bool) *Cell

SetFontItalic 设置字体斜体

func (*Cell) SetFontItalicFunc

func (my *Cell) SetFontItalicFunc(condition func() (bool, bool)) *Cell

SetFontItalicFunc 设置字体斜体:函数

func (*Cell) SetFontRgb

func (my *Cell) SetFontRgb(fontRgb string, condition bool) *Cell

SetFontRgb 设置字体颜色

func (*Cell) SetFontRgbFunc

func (my *Cell) SetFontRgbFunc(condition func() (string, bool)) *Cell

SetFontRgbFunc 设置字体颜色:函数

func (*Cell) SetFontSize

func (my *Cell) SetFontSize(fontSize float64, condition bool) *Cell

SetFontSize 设置字体字号

func (*Cell) SetFontSizeFunc

func (my *Cell) SetFontSizeFunc(condition func() (float64, bool)) *Cell

SetFontSizeFunc 设置字体字号:函数

func (*Cell) SetPatternRgb

func (my *Cell) SetPatternRgb(patternRgb string, condition bool) *Cell

SetPatternRgb 设置填充色

func (*Cell) SetPatternRgbFunc

func (my *Cell) SetPatternRgbFunc(condition func() (string, bool)) *Cell

SetPatternRgbFunc 设置填充色:函数

func (*Cell) SetWrapText

func (my *Cell) SetWrapText(wrapText bool) *Cell

SetWrapText 设置自动换行

type CellContentType

type CellContentType string

CellContentType 单元格内容类型

const (
	CellContentTypeAny     CellContentType = "any"
	CellContentTypeFormula CellContentType = "formula"
	CellContentTypeInt     CellContentType = "int"
	CellContentTypeFloat64 CellContentType = "float64"
	CellContentTypeBool    CellContentType = "bool"
	CellContentTypeTime    CellContentType = "time"
)

type Reader

type Reader struct {
	Err error
	// contains filtered or unexported fields
}

Reader Excel读取器

func NewReader

func NewReader() *Reader

NewReader 构造函数

func (*Reader) AutoRead

func (my *Reader) AutoRead(filename ...any) *Reader

AutoRead 自动读取(默认第一行是表头,从第二行开始,默认Sheet名称为:Sheet1)

func (*Reader) AutoReadBySheetName

func (my *Reader) AutoReadBySheetName(sheetName string, filename ...any) *Reader

AutoReadBySheetName 自动读取(默认第一行是表头,从第二行开始)

func (*Reader) Data

Data 获取数据:有序字典

func (*Reader) DataWithTitle

func (my *Reader) DataWithTitle() (*dict.AnyOrderlyDict[uint64, *dict.AnyDict[string, string]], error)

DataWithTitle 获取数据:带有title的有序字典

func (*Reader) GetFinishedRow

func (my *Reader) GetFinishedRow() int

GetFinishedRow 获取读取终止行

func (*Reader) GetOriginalRow

func (my *Reader) GetOriginalRow() int

GetOriginalRow 获取读取起始行

func (*Reader) GetSheetName

func (my *Reader) GetSheetName() string

GetSheetName 获取工作表名称

func (*Reader) GetTitle

func (my *Reader) GetTitle() *array.AnyArray[string]

GetTitle 获取表头

func (*Reader) GetTitleRow

func (my *Reader) GetTitleRow() int

GetTitleRow 获取表头行

func (*Reader) OpenFile

func (my *Reader) OpenFile(filename ...any) *Reader

OpenFile 打开文件

func (*Reader) Read

func (my *Reader) Read() *Reader

Read 读取Excel

func (*Reader) ReadTitle

func (my *Reader) ReadTitle() *Reader

ReadTitle 读取表头

func (*Reader) SetDataByRow

func (my *Reader) SetDataByRow(rowNumber uint64, data []string) *Reader

SetDataByRow 设置单行数据

func (*Reader) SetFinishedRow

func (my *Reader) SetFinishedRow(finishedRow int) *Reader

SetFinishedRow 设置读取终止行

func (*Reader) SetOriginalRow

func (my *Reader) SetOriginalRow(originalRow int) *Reader

SetOriginalRow 设置读取起始行

func (*Reader) SetSheetName

func (my *Reader) SetSheetName(sheetName string) *Reader

SetSheetName 设置工作表名称

func (*Reader) SetTitle

func (my *Reader) SetTitle(titles []string) *Reader

SetTitle 设置表头

func (*Reader) SetTitleRow

func (my *Reader) SetTitleRow(titleRow int) *Reader

SetTitleRow 设置表头行

func (*Reader) ToDataFrame

func (my *Reader) ToDataFrame(titleWithType map[string]series.Type) dataframe.DataFrame

ToDataFrame 获取DataFrame类型数据

func (*Reader) ToDataFrameDefaultType

func (my *Reader) ToDataFrameDefaultType() dataframe.DataFrame

ToDataFrameDefaultType 获取DataFrame类型数据 通过Excel表头自定义数据类型

func (*Reader) ToDataFrameDetectType

func (my *Reader) ToDataFrameDetectType() dataframe.DataFrame

ToDataFrameDetectType 获取DataFrame类型数据 通过自动探寻数据类型

type Row

type Row struct {
	Err error
	// contains filtered or unexported fields
}

Row Excel行

func NewRow

func NewRow() *Row

NewRow 构造函数

func (*Row) GetCells

func (my *Row) GetCells() *array.AnyArray[*Cell]

GetCells 获取单元格组

func (*Row) GetRowNumber

func (my *Row) GetRowNumber() uint64

GetRowNumber 获取行标

func (*Row) SetCells

func (my *Row) SetCells(cells []*Cell) *Row

SetCells 设置单元格组

func (*Row) SetRowNumber

func (my *Row) SetRowNumber(rowNumber uint64) *Row

SetRowNumber 设置行标

type Writer

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

Writer Excel写入器

func NewWriter

func NewWriter(filename ...any) *Writer

NewWriter 初始化

func (*Writer) ActiveSheetByIndex

func (my *Writer) ActiveSheetByIndex(sheetIndex int) *Writer

ActiveSheetByIndex 选择工作表(根据编号)

func (*Writer) ActiveSheetByName

func (my *Writer) ActiveSheetByName(sheetName string) *Writer

ActiveSheetByName 选择工作表(根据名称)

func (*Writer) AddRow

func (my *Writer) AddRow(excelRow *Row) *Writer

AddRow 增加一行行数据

func (*Writer) CreateSheet

func (my *Writer) CreateSheet(sheetName string) *Writer

CreateSheet 创建工作表

func (*Writer) Download

func (my *Writer) Download(writer http.ResponseWriter) error

Download 下载Excel

func (*Writer) GetExcelizeFile

func (my *Writer) GetExcelizeFile() *excelize.File

GetExcelizeFile 获取excelize文件对象

func (*Writer) GetFilename

func (my *Writer) GetFilename() string

GetFilename 获取文件名

func (*Writer) Save

func (my *Writer) Save() error

Save 保存文件

func (*Writer) SetColumnWidthByIndex

func (my *Writer) SetColumnWidthByIndex(col int, width float64) *Writer

SetColumnWidthByIndex 设置单列宽:通过列索引

func (*Writer) SetColumnWidthByText

func (my *Writer) SetColumnWidthByText(col string, width float64) *Writer

SetColumnWidthByText 设置单列宽:通过列名称

func (*Writer) SetColumnsWidthByIndex

func (my *Writer) SetColumnsWidthByIndex(startCol, endCol int, width float64) *Writer

SetColumnsWidthByIndex 设置多列宽:通过列索引

func (*Writer) SetColumnsWidthByText

func (my *Writer) SetColumnsWidthByText(startCol, endCol string, width float64) *Writer

SetColumnsWidthByText 设置多列宽:通过列名称

func (*Writer) SetFilename

func (my *Writer) SetFilename(filename string) *Writer

SetFilename 设置文件名

func (*Writer) SetRows

func (my *Writer) SetRows(excelRows []*Row) *Writer

SetRows 设置行数据

func (*Writer) SetSheetName

func (my *Writer) SetSheetName(sheetName string) *Writer

SetSheetName 设置sheet名称

func (*Writer) SetTitleRow

func (my *Writer) SetTitleRow(titles []string, rowNumber uint64) *Writer

SetTitleRow 设置标题行

Jump to

Keyboard shortcuts

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