excelHelper

package
v1.5.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLetter

func GetLetter(index int) string

GetLetter 获取列名(字母)

Types

type ExcelHelper

type ExcelHelper struct {
	ExcelFile *excelize.File // Excel文件
	SheetName string         // 左下角页面名
}

ExcelHelper Excel助手

func NewExcelHelper

func NewExcelHelper(sheetName string) (helper *ExcelHelper)

NewExcelHelper 创建一个单页Excel助手

func (*ExcelHelper) GetSimpleCellStyle

func (helper *ExcelHelper) GetSimpleCellStyle(styleObj *SimpleCellStyle) (cellStyle int, err error)

GetSimpleCellStyle 获取简单单元格样式

func (*ExcelHelper) SaveLocal

func (helper *ExcelHelper) SaveLocal(dirPath string) (filePath, fileName, ymdStr string, err error)

SaveLocal 保存到本地 dirPath:绝对路径,末尾不要接/,例子:"/home/go_project/space-api/excel" 主意这个文件夹要777

func (*ExcelHelper) SetCellStyle

func (helper *ExcelHelper) SetCellStyle(rowNo int, fromColumnNum, endColumnNum int, styleObj *SimpleCellStyle) (err error)

SetCellStyle 直接设置单元格格式

func (*ExcelHelper) SetCellValue

func (helper *ExcelHelper) SetCellValue(rowNo int, columnNum int, value interface{}) (err error)

SetCellValue 设置一个单元格的值

func (*ExcelHelper) SetCellValues

func (helper *ExcelHelper) SetCellValues(rowNo int, valueSlice []interface{}) (err error)

SetCellValues 批量设置数据(每个单元格占一行)

func (*ExcelHelper) SetMergedCellValue

func (helper *ExcelHelper) SetMergedCellValue(rowNo int, fromColumnNum, endColumnNum int, value interface{}) (err error)

SetMergedCellValue 设置一个占多个单元格的值(例如标题)

func (*ExcelHelper) SetRowHeight

func (helper *ExcelHelper) SetRowHeight(rowNo int, rowHeight float64) error

SetRowHeight 设置行高

func (*ExcelHelper) SetTableTitle

func (helper *ExcelHelper) SetTableTitle(rowNo int, slice []HeaderSlice) (err error)

SetTableTitle 设置表头的列名(ID、姓名、手机...)

type HeaderSlice

type HeaderSlice struct {
	Label string
	Width float64
}

type SimpleCellStyle

type SimpleCellStyle struct {
	BgColor     string // 背景色,默认 #E4E7ED
	BgColorFill bool   // 是否填充背景色,默认false

	FontSize  float64 // 字体大小,默认14
	FontBold  bool    // 字体加粗,默认false
	FontColor string  // 字体颜色,默认#303133

	BorderFill  bool   // 是否需要边框,默认false
	BorderColor string // 边框颜色,默认#303133

	IsMoneyField bool // 是否填充背景色,默认false
}

SimpleCellStyle 简单单元格格式

Jump to

Keyboard shortcuts

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