importer

package
v0.9.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseCSVFilenamePattern added in v0.9.7

func ParseCSVFilenamePattern(filename string) (bookName, sheetName string)

Types

type CSVImporter

type CSVImporter struct {
	*book.Book
}

CSVImporter recognizes pattern: "<BookName>#<SheetName>.csv"

func NewCSVImporter

func NewCSVImporter(filename string, sheetNames []string, parser book.SheetParser) (*CSVImporter, error)

type ExcelImporter

type ExcelImporter struct {
	*book.Book
}

func NewExcelImporter

func NewExcelImporter(filename string, sheetNames []string, parser book.SheetParser) (*ExcelImporter, error)

type Importer

type Importer interface {
	// Filename returns the parsed filename of the original inputed filename.
	// 	- Excel: same as the inputed filename.
	// 	- CSV: recognizes pattern: "<BookName>#<SheetName>.csv", and returns Glob name "<BookName>#*.csv".
	// 	- XML: same as the inputed filename.
	Filename() string
	// Bookname returns the book name after parsing the original inputed filename.
	// 	- Excel: the base filename without file extension.
	// 	- CSV: recognizes pattern: "<BookName>#<SheetName>.csv", and returns "<BookName>".
	// 	- XML: the base filename without file extension.
	BookName() string
	// GetSheets returns all sheets in order of the book.
	GetSheets() []*book.Sheet
	// GetSheet returns a Sheet of the specified sheet name.
	GetSheet(name string) *book.Sheet
}

func New

func New(filename string, setters ...Option) (Importer, error)

type Option

type Option func(*Options)

Option is the functional option type.

func Parser

func Parser(parser book.SheetParser) Option

func Sheets

func Sheets(sheets []string) Option

type Options

type Options struct {
	Sheets []string         // sheet names to import
	Parser book.SheetParser // parser to parse the worksheet
}

type Pass added in v0.9.1

type Pass int

type Range added in v0.9.1

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

type XMLImporter

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

func NewXMLImporter

func NewXMLImporter(filename string, sheets []string) (*XMLImporter, error)

TODO: options

func (*XMLImporter) BookName added in v0.9.7

func (x *XMLImporter) BookName() string

func (*XMLImporter) Filename added in v0.9.7

func (x *XMLImporter) Filename() string

func (*XMLImporter) GetSheet

func (x *XMLImporter) GetSheet(name string) *book.Sheet

GetSheet returns a Sheet of the specified sheet name.

func (*XMLImporter) GetSheets

func (x *XMLImporter) GetSheets() []*book.Sheet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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