def col_by_name(colname):
    """'A' -> 0, 'Z' -> 25, 'AA' -> 26, etc
    """
    col = 0
    power = 1
    for i in range(len(colname) - 1, -1, -1):
        ch = colname[i]
        col += (ord(ch) - ord('A') + 1) * power
        power *= 26
    return col - 1
