Documentation
¶
Index ¶
- Variables
- func ResolveSheetSpecifier(inputDir, primaryBookName string, sheetSpecifier string, ...) (relBookPaths map[string]bool, sheetNamePattern string, err error)
- type CSVImporter
- type Cache
- func (c *Cache) EnableProfiling()
- func (c *Cache) Load(ctx context.Context, filename string, setters ...Option) (Importer, error)
- func (c *Cache) LoadMergerImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, ...) ([]ImporterInfo, error)
- func (c *Cache) LoadScatterImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, ...) ([]ImporterInfo, error)
- func (c *Cache) Metrics() (requests, imports, sheets, paths int64)
- type ExcelImporter
- type Importer
- type ImporterInfo
- type ImporterMode
- type Option
- type Options
- type XMLImporter
- type YAMLImporter
Constants ¶
This section is empty.
Variables ¶
var BOM = []byte{0xEF, 0xBB, 0xBF}
BOM stands for byte-order mark. Refer: https://en.wikipedia.org/wiki/Byte_order_mark.
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 Cache ¶ added in v0.17.0
type Cache struct {
// contains filtered or unexported fields
}
Cache reuses imported data while it remains reachable. Sources own decoded sheets and workbook handles; entries are immutable importer views for one option set. Load may be called concurrently. The cache has no shutdown step.
func (*Cache) EnableProfiling ¶ added in v0.17.0
func (c *Cache) EnableProfiling()
EnableProfiling enables pprof labels and cache metrics. Call it before the cache is used.
func (*Cache) Load ¶ added in v0.17.0
Load returns a cached importer or loads it once for concurrent callers.
func (*Cache) LoadMergerImporters ¶ added in v0.17.0
func (c *Cache) LoadMergerImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, sheetSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
LoadMergerImporters returns related merger importers through the cache. A nil cache performs direct loads.
func (*Cache) LoadScatterImporters ¶ added in v0.17.0
func (c *Cache) LoadScatterImporters(ctx context.Context, inputDir, primaryBookName, primarySheetName string, sheetSpecifiers []string, subdirRewrites map[string]string) ([]ImporterInfo, error)
LoadScatterImporters returns related scatter importers through the cache. A nil cache performs direct loads.
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
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
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package xlsx reads raw cell values from selected OOXML worksheets.
|
Package xlsx reads raw cell values from selected OOXML worksheets. |