根據(jù)下標(biāo)生成類似A-Z AA-AZ的excel表頭
func main() {
fmt.Println(getKey(0))
fmt.Println(getKey(26))
fmt.Println(getKey(45))
}
// 根據(jù)下標(biāo) 獲取 對應(yīng)表頭
func getKey(index int) string {
colCode := ""
key := 'A'
loop := index / 26
if loop > 0 {
colCode += getKey(loop - 1)
}
return colCode + string(key+int32(index)%26)
}