In my code below I'm using the exclize library to read data from an excel sheet.
My problem is that the .GetRows
method reads the entier sheet when I'm only interested in getting the data from a few columns.
Looking through the goDoc I couldn't find a method that gives you the data based on column index or name.
Is there a way, in spite of this, to only read the data from a select few columns? Or limit the range of the .GetRows
method somehow
Here's the code:
package main
import (
"fmt"
"github.com/360EntSecGroup-Skylar/excelize"
)
type AllData struct {
Name, Team, SSN string
}
var mapping []AllData
func main() {
fileName := "Blad1"
xlsx, err := excelize.OpenFile(fileName + ".xlsx")
if err != nil {
fmt.Println(err)
return
}
rows := xlsx.GetRows(fileName)
for _, row := range rows[1:] {
mapping = append(mapping, AllData{ Name: row[0] })
}
m := map[string]interface{}{
"Data": mapping,
}
fmt.Println(m["Data"])
}