如何使用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 {

 }

}

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]

推荐一个功能丰富、兼容性好、高性能的 Excel 文档基础库 Excelize:https://github.com/xuri/excelize