在Golang中读取Excel文件时出错

I was trying the below code but I get an error

"multiple-value cell.String() in single-value context"

Code

 package main
import (
"fmt"
"github.com/tealeg/xlsx"
 )
 func main() { 
     excelFileName := "test.xlsx"
     xlFile, err := xlsx.OpenFile(excelFileName)
     if err != nil {

     }
 for _, sheet := range xlFile.Sheets {
    for _, row := range sheet.Rows {
          for _, cell := range row.Cells {
            fmt.Printf("%s ", cell.String(), "123")
  }
            fmt.Printf("
")
  }
  }
 }
}

change

for _, cell := range row.Cells {
    fmt.Printf("%s ", cell.String(), "123")
}

to

for _, cell := range row.Cells {
    val, _ := cell.String()
    fmt.Printf("%s ", val)
}

You are trying to use a function that returns multiple values as a single argument (to fmt.Printf())

If you don't think you will get any errors, you can just assign it to _ and ignore it, but you really should be prepared to handle the error. This is why Go forces you to use variables and why it doesn't automatically discard other return values (like the error from cell.String())

val, err := cell.String()
if err != nil {
    // handle the error
}
fmt.Printf("%s ", val) // you had an extra arg of "123"?