Documentation ¶
Index ¶
- Variables
- func NeedSheet(sheetName string, wantSheetNames []string) bool
- func ParseSheetSpecifier(specifier string) (bookNameGlob string, specifiedSheetName string)
- func ResolveSheetSpecifier(inputDir, primaryBookName string, sheetSpecifier string, ...) (map[string]bool, string, 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 ErrSheetNotFound = errs.New("sheet not found")
Functions ¶
func ParseSheetSpecifier ¶ added in v0.11.0
ParseSheetSpecifier parses the sheet specifier pattern like: "<BookNameGlob>[#SheetName]".
- The delimiter between BookNameGlob and SheetName is "#".
- The "SheetName" is optional, default is same as sheet name in the primary workbook.
func ResolveSheetSpecifier ¶ added in v0.11.0
func ResolveSheetSpecifier(inputDir, primaryBookName string, sheetSpecifier string, subdirRewrites map[string]string) (map[string]bool, string, error)
ResolveSheetSpecifier resolve and return all related workbook paths.
- support Glob pattern, refer https://pkg.go.dev/path/filepath#Glob
- exclude self
- special process for CSV filename pattern: "<BookName>#<SheetName>.csv"
Types ¶
type CSVImporter ¶
CSVImporter recognizes pattern: "<BookName>#<SheetName>.csv"
func NewCSVImporter ¶
func NewCSVImporter(filename string, sheetNames []string, parser book.SheetParser, mode ImporterMode, cloned bool) (*CSVImporter, error)
type ExcelImporter ¶
func NewExcelImporter ¶
func NewExcelImporter(filename string, sheetNames []string, parser book.SheetParser, mode ImporterMode, cloned bool) (*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 // Format returns workboot format. Format() format.Format // Metabook returns the metadata of the book. Metabook() *tableaupb.Metabook // 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(inputDir, primaryBookName, sheetName string, sheetSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
GetMergerImporters return all related importer infos.
- support Glob pattern, refer https://pkg.go.dev/path/filepath#Glob
- exclude self
- special process for CSV filename pattern: "<BookName>#<SheetName>.csv"
func GetScatterImporters ¶ added in v0.10.7
func GetScatterImporters(inputDir, primaryBookName, sheetName string, scatterSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
GetScatterImporters return all related importer infos.
- support Glob pattern, refer https://pkg.go.dev/path/filepath#Glob
- exclude self
- special process for CSV filename pattern: "<BookName>#<SheetName>.csv"
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 Mode ¶ added in v0.10.6
func Mode(m ImporterMode) Option
func Parser ¶
func Parser(parser book.SheetParser) Option
type Options ¶
type Options struct { Sheets []string // sheet names 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 ¶
func NewXMLImporter(filename string, sheets []string, parser book.SheetParser, mode ImporterMode, cloned bool) (*XMLImporter, error)
type YAMLImporter ¶ added in v0.11.0
func NewYAMLImporter ¶ added in v0.11.0
func NewYAMLImporter(filename string, sheetNames []string, parser book.SheetParser, mode ImporterMode, cloned bool) (*YAMLImporter, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.