I am trying to write a function that writes a string array to excel in Go, using Excelize. My question: how to address a cell with row number and col number, instead of the "A1" type of syntax for the "axis" parameter ?
// Writes the header of the file:
xlfile.SetCellValue("Sheet1", "A1", "1")
// Instead of "A1", I would like to use row number and col number as parameters
CoordinatesToCellName converts [X, Y] coordinates to alpha-numeric cell name or returns an error.
excelize.ColumnNumberToName(colIndex) 索引转列名
```go
//遍历数组中所有元素追加成string
func arrayToString(arr []string) string {
var result string
for _, i := range arr {
result += i
}
return result
}
//通过列索引返回列名
func GetCellNameByIndex(index int) string {
//A:65 ~ Z:90
if index <= int('A') {
return "A"
}
n := (index - int('A')) / 26
if n == 0 {
return string(rune(index))
}
var letters = []string {""}
for i := 0; i < n; i++ {
letters = append(letters, "A")
}
mod := (index - int('A')) % 26
if mod > 0 {
letters = append(letters, string(rune(int('A')+mod)))
}else{
letters = append(letters, "A")
}
return arrayToString(letters)
}
```