excel_to_gorm

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CellToType

func CellToType(c *xlsx.Cell, outType reflect.Type, params Params) reflect.Value

takes an excel cell and converts it to a reflect.Value of a given type (supplied as a reflect.Type) used internally, but exposed as it may have uses elsewhere

func CopyIdenticalFields added in v0.0.4

func CopyIdenticalFields(copyFrom, copyInto interface{})

copies data from a to b between different structs where the field names are identical eg. where the API fields are a subset of the database fields example usage: api.SomeInterface := some data var models.SomeInterface CopyIdenticalFields()

func ExcelFileToSlice

func ExcelFileToSlice(fileName string, sheetName string, model interface{}, params Params) (interface{}, error)

func GetHeadings

func GetHeadings(fileName string, sheetName string) ([]string, error)

get the first row of a worksheet, whixch is assumed to be the column heading names

func GetSheetNameMap

func GetSheetNameMap(fileName string) (map[string]int, error)

func GetSheetNames

func GetSheetNames(fileName string) ([]string, error)

func WorkbookToSlice

func WorkbookToSlice(wb *xlsx.File, sheetName string, model interface{}, params Params) (interface{}, error)

allows calling function to keep file open calling function needs to import "github.com/tealeg/xlsx/v3" and pass a pointer to an xlsx.File eg.: wb, err := xlsx.OpenFile(fileName)

func WorksheetToSlice

func WorksheetToSlice(sh *xlsx.Sheet, model interface{}, params Params) (interface{}, error)

allows calling function to keep sheet open calling function needs to close the sheet calling function needs to import "github.com/tealeg/xlsx/v3" and pass a pointer to an xlsx.Sheet eg.: sh, ok := wb.Sheet[sheetName]

Types

type Params

type Params struct {
	ColMap          map[string]int    // maps fieldnames to column numbers(starting at 1).  Overrides tagnames if mapping present
	ConstMap        map[string]string // maps from tagname mapConst:Mapfrom to a string constant to be parsed into the field
	FirstRowHasData bool
	ErrorOnNaN      bool
}

type Tag

type Tag struct {
	HasTag         bool
	HasColanme     bool
	Colname        string
	IsIntColsHead  bool
	IsIntColsValue bool
	IsMapConst     bool
	ConstMapKey    string
	IsMeltHead     bool
	IsMeltValue    bool
	Ignore         []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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