Documentation
¶
Index ¶
- Variables
- func ResolveSheetSpecifier(inputDir, primaryBookName string, sheetSpecifier string, ...) (relBookPaths map[string]bool, sheetNamePattern string, err error)
- type CSVImporter
- type ExcelImporter
- type Importer
- type ImporterInfo
- type ImporterMode
- type Option
- type Options
- type XMLImporter
- type YAMLImporter
Constants ¶
This section is empty.
Variables ¶
View Source
var BOM = []byte{0xEF, 0xBB, 0xBF}
BOM stands for byte-order mark. Refer: https://en.wikipedia.org/wiki/Byte_order_mark.
View Source
var ErrSheetNotFound = errors.New("sheet not found")
Functions ¶
func ResolveSheetSpecifier ¶ added in v0.11.0
func ResolveSheetSpecifier(inputDir, primaryBookName string, sheetSpecifier string, subdirRewrites map[string]string) (relBookPaths map[string]bool, sheetNamePattern string, err error)
ResolveSheetSpecifier resolves and returns all related workbook paths and sheet names.
- support filepath.Glob pattern for workbook file, see https://pkg.go.dev/path/filepath#Glob
- special process for CSV filename pattern: "<BookNamePattern>#<SheetNamePattern>.csv"
Types ¶
type CSVImporter ¶
CSVImporter recognizes pattern: "<BookName>#<SheetName>.csv"
func NewCSVImporter ¶
type ExcelImporter ¶
func NewExcelImporter ¶
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
// Format returns workboot format.
Format() format.Format
// GetBookOptions creates a new tableaupb.WorkbookOptions
// based on this special sheet(#)'s info.
GetBookOptions() *tableaupb.WorkbookOptions
// 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
}
type ImporterInfo ¶ added in v0.11.0
func GetMergerImporters ¶ added in v0.10.6
func GetMergerImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, sheetSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
GetMergerImporters parses and returns all related importer infos for merger.
func GetScatterImporters ¶ added in v0.10.7
func GetScatterImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, sheetSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
GetScatterImporters parses and returns all related importer infos for scatter.
type ImporterMode ¶ added in v0.10.6
type ImporterMode int
const ( UnknownMode ImporterMode = 0 Protogen ImporterMode = 1 Confgen ImporterMode = 2 )
Importer mode
type Option ¶
type Option func(*Options)
Option is the functional option type.
func Cloned ¶ added in v0.10.7
Cloned specifies this book cloned (same schema different data) from the main book.
func Parser ¶
func Parser(parser book.SheetParser) Option
Parser specifies parser to parse the worksheet.
type Options ¶
type Options struct {
Sheets []string // sheet name patterns (by filepath.Match) to import
Parser book.SheetParser // parser to parse the worksheet
Mode ImporterMode // importer mode
Cloned bool // this book cloned (same schema different data) from the main book
PrimaryBookName string // if cloned, this is primary book name
}
type XMLImporter ¶
func NewXMLImporter ¶
type YAMLImporter ¶ added in v0.11.0
func NewYAMLImporter ¶ added in v0.11.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.