// NewSqlTableByQuery func NewSqlTableByQuery(db *mdb.Sql, sql string, args ...interface{}) *SqlTable { logger.Trace("NewSqlTableByQuery()") table := new(SqlTable) bt := new(msdb.BaseTable) cu := new(msdb.Cusor) table.Sql = db rows, _ := table.GetQueryRows(sql, args...) cu.MaxIndex = int(rows) colsNames, err := table.GetQueryColumns(sql, args...) if err != nil { fmt.Println(err) } bt.Header = colsNames table.data = table.QueryForData(sql, args...) table.BaseTable = bt table.BaseTable.Cusor = cu table.StringGetter = table return table }
// NewXlsxTableBySheet returns XlsxTable func NewXlsxTableBySheet(sheet *wxlsx.Sheet) (*XlsxTable, error) { table := new(XlsxTable) bt := new(msdb.BaseTable) cu := new(msdb.Cusor) table.sheet = sheet cu.MaxIndex = len(sheet.Rows) - 1 bt.Cusor = cu bt.Header = GetHeader(sheet) table.BaseTable = bt table.StringGetter = table return table, nil }