excel

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColumnLetter = [...]string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC"}
View Source
var HeaderStyle = &excelize.Style{
	Border: []excelize.Border{{
		Type:  "left",
		Color: "000000",
		Style: 1,
	},
		{
			Type:  "top",
			Color: "000000",
			Style: 1,
		},
		{
			Type:  "bottom",
			Color: "000000",
			Style: 1,
		},
		{
			Type:  "right",
			Color: "000000",
			Style: 1,
		}},
	Fill: excelize.Fill{
		Type:    "pattern",
		Pattern: 1,
		Color:   []string{"#bfbfbf"},
	},
	Font: &excelize.Font{Bold: true},
	Alignment: &excelize.Alignment{
		Horizontal: "center",
		Vertical:   "center",
	},
	Protection:   nil,
	NumFmt:       0,
	CustomNumFmt: nil,
	NegRed:       false,
}
View Source
var Style = &excelize.Style{
	Alignment: &excelize.Alignment{
		Horizontal: "center",
		Vertical:   "center",
	},
}

Functions

func MergeCell added in v0.3.7

func MergeCell(sw *excelize.StreamWriter, startRowNum, endRowNum int, cells []string)

合并单元格 参数

sw, excel StreamWriter
startRowNum, 要合并开始的excel行号
endRowNum, 要合并结束的excel行号
cells, 要合并单元格的列("A","B","C")

func NewFile

func NewFile(sheet string, header []string) (*excelize.File, error)

func NewSheet

func NewSheet(f *excelize.File, sheet string, header []string) error

func SetBodyRow added in v0.3.7

func SetBodyRow(sw *excelize.StreamWriter, f *excelize.File, rowNum int, cellVal []any)

SetBodyRow

为excel stream设置行

参数

sw, excel StreamWriter
rowNum, 要设置的excel行号,行号是从1开始的,第一行行号为1
cellVal, 单元格内容

func SetBodyRow2 added in v0.3.7

func SetBodyRow2(sw *excelize.StreamWriter, f *excelize.File, rowNum int, cellVal []string, errStyleLoc map[int]byte)

SetBodyRow2

为excel stream设置行

参数

sw, excel StreamWriter
rowNum, 要设置的excel行号,行号是从1开始的,第一行行号为1
cellVal, 单元格内容
errStyleLoc, 红色错误样式的单元格位置

func SetCellDropListStyle added in v0.3.7

func SetCellDropListStyle(sw *excelize.StreamWriter, f *excelize.File, hiddenSheetName string, dropListSize int, effectCellStart, effectCellEnd string)

SetCellDropListStyle 设置单元格下拉框选项样式,根据提供的下拉列表枚举值,作为单元格内容待候选值

	当下拉框列表太大时,无法直接采用AddDataValidation的形式添加
	这里通过将下拉枚举列表提前写入到隐藏的Sheet中,然后引用此隐藏Sheet再加载的方式实现
 @param sw excel streamWriter
 @param f excel file
 @param hiddenSheetName 存在此f中的隐藏Sheet
 @param dropListSize 下拉列表容量大小
 @param effectCellStart effectCellEnd 下拉框选项样式作用的单元格范围 起始位置 结束位置 例如 K2 K31

func SetHeaderRow added in v0.3.7

func SetHeaderRow(sw *excelize.StreamWriter, f *excelize.File, rowNum int, colWith float64, headers []string)

SetHeaderRow

为excel stream设置表头

参数

sw, excel StreamWriter
rowNum, 要作为表头的excel行号,行号是从1开始的,第一行行号为1
colWidth, 列宽, 为0时表示采用默认不设置
headers, 表头文案列表

func SetNoteRow added in v0.3.7

func SetNoteRow(sw *excelize.StreamWriter, f *excelize.File, rowNum, maxCol int, rowHeight float64, note string) error

SetNoteRow

为excel stream设置提醒行

参数

sw, excel StreamWriter
rowNum, 要作为提醒文本行的excel行号,行号是从1开始,第一行行号为1
maxCol, 提醒文本最多占用多少格
rowHeight, 行高
note, 提醒文案

Types

type ColumnNumber

type ColumnNumber int
const (
	A ColumnNumber = iota
	B
	C
	D
	E
	F
	G
	H
	I
	J
	K
	L
	M
	N
	O
	P
	Q
	R
	S
	T
	U
	V
	W
	X
	Y
	Z
	AA
	AB
	AC
)

func (ColumnNumber) Sting

func (c ColumnNumber) Sting() string

只拓展到两位列ZZ

Jump to

Keyboard shortcuts

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