package helpers
import (
"time"
"strconv"
)
// ExcelError is an error implementation that includes a time and message.
type ExcelError struct {
When time.Time
What string
}
// Return the ColumnName
func GetColumnName(rowNumber int, colNumber int)(colName string, err error) {
if rowNumber < 1 || colNumber < 1 {
err = ExcelError{
time.Now(),
"Row and Column Number can not be less than 1",
}
return
}
dividend := colNumber
var modulo int
for dividend > 0 {
modulo = (dividend - 1) % 26
// Convert int to char
colName = string(65+modulo) + colName
dividend = (int)((dividend - modulo) / 26)
}
colName = colName + strconv.Itoa(rowNumber)
return
}