From 0faa29f2c11a6d906f340397eca5c4bc6d0f1dc6 Mon Sep 17 00:00:00 2001 From: George Abbott Date: Fri, 3 Nov 2023 21:06:29 +0000 Subject: Commit all --- header.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 header.go (limited to 'header.go') diff --git a/header.go b/header.go new file mode 100644 index 0000000..d553945 --- /dev/null +++ b/header.go @@ -0,0 +1,22 @@ +package badtudexo + +import ( + xl "git.gabbott.dev/george/excelize/v2" + // st "saggytrousers" +) + + +// Return the header of a given file, which must be the first row. +func GetHeader(file *xl.File, sheet string) ([]string, error) { + rows, err := file.Rows(sheet) + if err != nil { + return []string{}, err + } + + rows.Next() + header, err := rows.Columns() + if err != nil { + return []string{}, err + } + return header, nil +} -- cgit v1.2.1