user3616626
user3616626

Reputation: 11

How do I get the sheet's name using github.com/tealeg/xlsx?

I am using github.com/tealeg/xlsx to read XLSX files. It is read pretty fast, however I would like to read by Sheet Name. Does anyone know how to do?

// by sheet index works fine

xlFile,err := xlsx.OpenFile(xlsFile)

for _,sheet := range xlFile.Sheets {

 for _,row := range sheet.Rows {

 }

}

Upvotes: 1

Views: 1169

Answers (1)

Sebastian
Sebastian

Reputation: 17443

Just use the map Sheet contained in xlsx.File and access by key (the key is your sheet name):

xlFile, err := xlsx.OpenFile(xlsFile)
// check err

sheetName := "YourSheetName"
sheet := xlFile.Sheet[sheetName]

Upvotes: 4

Related Questions