package saggytrousers import ( xl "anyxcelize" "fmt" ) // Provides functions for getting the header as []string and the body (except // the header) as [][]any, which can be passed into other functions from there. func GetHeader(file *xl.File, sheet string) []string { rows, err := file.Rows(sheet) if err != nil { str := fmt.Sprintf("st.GetHeader: call to Rows(sheet: %s) failed with error %v", sheet, err) panic(str) } rows.Next() header, err := rows.Columns() if err != nil { str := fmt.Sprintf("st.GetHeader: Could not get a header.") panic(str) } return header } // Get all rows, except the header. func GetRows(file *xl.File, sheet string) [][]any { rows, err := file.GetRowsGeneric(sheet) if err != nil { str := fmt.Sprintf("saggytrousers.GetRows: call to GetRowsGeneric(%s) failed with error %v", sheet, err) panic(str) } return rows[1:] } func GetColumns(file *xl.File, sheet string) [][]any { cols, err := file.GetColsGeneric(sheet) if err != nil { str := fmt.Sprintf("saggytrousers.GetColumns: call to GetRowsGeneric(%s) failed with error %v", sheet, err) panic(str) } var ret [][]any for _, sa := range cols { exceptFirst := sa[1:] ret = append(ret, exceptFirst) } return ret }