excel

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ExtXls  = "xls"
	ExtXlsx = "xlsx"
)

Variables

This section is empty.

Functions

func GenAxis

func GenAxis(length int) []string

3 => [A, B, C]

func GetAxisName added in v1.0.1

func GetAxisName(col int) string

1=>A, 2=>B

func GetColNum added in v1.0.1

func GetColNum(axis string) int

A=》1,B=>2

func LoadExcel

func LoadExcel(filePath string) (excel *excelize.File, err error)

加载Excel文件,过滤无Sheet情况

func LoadExcels

func LoadExcels(path string) (excels []*excelize.File, err error)

加载路径下的Excel文件,多个路径用","分割 支持文件夹路径

func ParseAxis

func ParseAxis(axis string) (cellIndex int, rowIndex int, err error)

"A1" => 0, 0, nil

Types

type ExcelProxy

type ExcelProxy struct {
	Excels   []*excelize.File
	Sheets   []*ExcelSheet
	DataRows []*ExcelRow
}

func (*ExcelProxy) GetSheet

func (ep *ExcelProxy) GetSheet(sheet string) (es *ExcelSheet, err error)

func (*ExcelProxy) LoadExcel

func (ep *ExcelProxy) LoadExcel(excelPath string, overwrite bool) error

加载excelPath指定的一个或多个Excel文件。 excelPath支持多路径模式,用","分隔。 excelPath支持文件夹,不支持递归。

func (*ExcelProxy) LoadExcels

func (ep *ExcelProxy) LoadExcels(excelPath string, overwrite bool) error

加载excelPath指定的一个Excel文件。

func (*ExcelProxy) LoadSheets

func (ep *ExcelProxy) LoadSheets(sheetPrefix string, colNickRow int, overwrite bool) error

从已经加载好的Excel中加载Sheets sheetPrefix用于限制

func (*ExcelProxy) MergedRows

func (ep *ExcelProxy) MergedRows(startRow int) (err error)

合并全部sheet的行数据。 从StartRow开始。 清除空数据

func (*ExcelProxy) MergedRowsByFilter

func (ep *ExcelProxy) MergedRowsByFilter(startRow int, filter func(row *ExcelRow) bool) (err error)

合并全部sheet的行数据。 从StartRow开始。 清除空数据

func (*ExcelProxy) ValueAtAxis

func (ep *ExcelProxy) ValueAtAxis(sheet string, axis string) (value string, err error)

Open to templates 通过Sheet的名称和坐标取值,坐标格式:B4

type ExcelRow

type ExcelRow struct {
	Cell []string

	Index int
	Sheet *ExcelSheet
}

func (*ExcelRow) Axis

func (er *ExcelRow) Axis() []string

func (*ExcelRow) AxisLength

func (er *ExcelRow) AxisLength() int

func (*ExcelRow) CellLength

func (er *ExcelRow) CellLength() int

func (*ExcelRow) Empty

func (er *ExcelRow) Empty() bool

func (*ExcelRow) Nick

func (er *ExcelRow) Nick() []string

func (*ExcelRow) NickLength

func (er *ExcelRow) NickLength() int

func (*ExcelRow) String

func (er *ExcelRow) String() string

func (*ExcelRow) ValueAtAxis

func (er *ExcelRow) ValueAtAxis(axis string) (value string, err error)

Open to templates 通过列名取值

func (*ExcelRow) ValueAtIndex

func (er *ExcelRow) ValueAtIndex(index int) (value string, err error)

Open to templates 通过索引号取值,索引号从0开始

func (*ExcelRow) ValueAtNick

func (er *ExcelRow) ValueAtNick(nick string) (value string, err error)

Open to templates 通过别名取值

type ExcelSheet

type ExcelSheet struct {
	SheetIndex int    // Sheet的索引
	SheetName  string // Sheet的名称

	Axis []string // 列名
	Nick []string // 列别名

	RowLength int         // 行数
	Rows      []*ExcelRow // 全部行内容
}

func LoadSheets

func LoadSheets(excelFile *excelize.File, sheetPrefix string, nickRow int) (sheets []*ExcelSheet, err error)

通过SheetPrefix作为限制加载Sheet, 使用""代表不限制 指定NickRow所在行为别名,NickRow=0时,使用列号作为别名

func (*ExcelSheet) AxisLength

func (es *ExcelSheet) AxisLength() int

func (*ExcelSheet) GetRowAt

func (es *ExcelSheet) GetRowAt(rowIndex int) (row *ExcelRow)

func (*ExcelSheet) GetRowsBetween

func (es *ExcelSheet) GetRowsBetween(startIndex int, endIndex int) (rows []*ExcelRow)

func (*ExcelSheet) GetRowsByFilter

func (es *ExcelSheet) GetRowsByFilter(startIndex int, filter func(row *ExcelRow) bool) (rows []*ExcelRow)

func (*ExcelSheet) GetRowsFrom

func (es *ExcelSheet) GetRowsFrom(startIndex int) (rows []*ExcelRow)

func (*ExcelSheet) NickLength

func (es *ExcelSheet) NickLength() int

func (*ExcelSheet) SetNick

func (es *ExcelSheet) SetNick(nick []string)

func (*ExcelSheet) String

func (es *ExcelSheet) String() string

func (*ExcelSheet) ValueAtAxis

func (es *ExcelSheet) ValueAtAxis(axis string) (value string, err error)

Open to templates 通过坐标取值,坐标格式:B4

Jump to

Keyboard shortcuts

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