importer

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractFromCell

func ExtractFromCell(cell string, line int32) string

func OpenExcel

func OpenExcel(filename string, sheetName string) (*excelize.File, error)

Types

type CSVImporter

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

func NewCSVImporter

func NewCSVImporter(filename string) *CSVImporter

func (*CSVImporter) ExportExcel

func (x *CSVImporter) ExportExcel() error

func (*CSVImporter) GetSheet

func (x *CSVImporter) GetSheet(name string) (*Sheet, error)

GetSheet returns a Sheet of the specified sheet name.

func (*CSVImporter) GetSheets

func (x *CSVImporter) GetSheets() ([]*Sheet, error)

type ExcelImporter

type ExcelImporter struct {
	Meta *tableaupb.WorkbookMeta
	// contains filtered or unexported fields
}

func NewExcelImporter

func NewExcelImporter(filename string, sheets []string, parser SheetParser, includeMetaSheet bool) *ExcelImporter

TODO: options

func (*ExcelImporter) ExportCSV

func (x *ExcelImporter) ExportCSV() error

func (*ExcelImporter) GetSheet

func (x *ExcelImporter) GetSheet(name string) (*Sheet, error)

GetSheet returns a Sheet of the specified sheet name.

func (*ExcelImporter) GetSheets

func (x *ExcelImporter) GetSheets() ([]*Sheet, error)

func (*ExcelImporter) NeedParseMeta

func (x *ExcelImporter) NeedParseMeta() bool

type Importer

type Importer interface {
	// GetSheet returns a Sheet of the specified sheet name.
	GetSheets() ([]*Sheet, error)
	GetSheet(name string) (*Sheet, error)
}

func New

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

type Option

type Option func(*Options)

Option is the functional option type.

func Format

func Format(fmt options.Format) Option
func Header(header *options.HeaderOption) Option

func Parser

func Parser(sp SheetParser) Option

func Sheets

func Sheets(sheets []string) Option

type Options

type Options struct {
	Format options.Format        // file format: Excel, CSV, XML. Default: Excel.
	Sheets []string              // sheet names to import
	Parser SheetParser           // parser to parse the worksheet
	Header *options.HeaderOption // header settings.
}

type RowCell

type RowCell struct {
	Col  int    // cell column (0-based)
	Data string // cell data
	Type string // cell type
	Name string // cell name
	// contains filtered or unexported fields
}

type RowCells

type RowCells struct {
	Row int // row number
	// contains filtered or unexported fields
}

func NewRowCells

func NewRowCells(row int, prev *RowCells) *RowCells

func (*RowCells) Cell

func (r *RowCells) Cell(name string, optional bool) *RowCell

func (*RowCells) CellDebugString

func (r *RowCells) CellDebugString(name string) string

func (*RowCells) GetCellCountWithPrefix

func (r *RowCells) GetCellCountWithPrefix(prefix string) int

func (*RowCells) SetCell

func (r *RowCells) SetCell(name string, col int, data, typ string)

type Sheet

type Sheet struct {
	Name   string
	MaxRow int
	MaxCol int

	Rows [][]string // 2D array of string.

	Meta *tableaupb.SheetMeta
}

func NewSheet

func NewSheet(name string, rows [][]string) *Sheet

NewSheet creats a new Sheet.

func (*Sheet) Cell

func (s *Sheet) Cell(row, col int) (string, error)

Cell returns the cell at (row, col).

func (*Sheet) ExportCSV

func (s *Sheet) ExportCSV(writer io.Writer) error

func (*Sheet) ExportExcel

func (s *Sheet) ExportExcel(file *excelize.File) error

func (*Sheet) String

func (s *Sheet) String() string

String returns the string representation (CSV) of the sheet.

type SheetParser

type SheetParser interface {
	Parse(protomsg proto.Message, sheet *Sheet, wsOpts *tableaupb.WorksheetOptions) error
}

type XMLImporter

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

func NewXMLImporter

func NewXMLImporter(filename string, header *options.HeaderOption) *XMLImporter

TODO: options

func (*XMLImporter) GetSheet

func (x *XMLImporter) GetSheet(name string) (*Sheet, error)

GetSheet returns a Sheet of the specified sheet name.

func (*XMLImporter) GetSheets

func (x *XMLImporter) GetSheets() ([]*Sheet, error)

Jump to

Keyboard shortcuts

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