We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4e6457a commit b18b480Copy full SHA for b18b480
lib.go
@@ -232,12 +232,18 @@ func ColumnNumberToName(num int) (string, error) {
232
if num < MinColumns || num > MaxColumns {
233
return "", ErrColumnNumber
234
}
235
- var col string
+ estimatedLength := 0
236
+ for n := num; n > 0; n = (n - 1) / 26 {
237
+ estimatedLength++
238
+ }
239
+
240
+ result := make([]byte, estimatedLength)
241
for num > 0 {
- col = string(rune((num-1)%26+65)) + col
242
+ estimatedLength--
243
+ result[estimatedLength] = byte((num-1)%26 + 'A')
244
num = (num - 1) / 26
245
- return col, nil
246
+ return string(result), nil
247
248
249
// CellNameToCoordinates converts alphanumeric cell name to [X, Y] coordinates
0 commit comments