import re


def _to_numeric_range(cell):
    """
    Translate an Excel cell (eg 'A1') into a (col, row) tuple indexed from zero.
    e.g. 'A1' returns (0, 0)
    """
    match = re.match("^\$?([A-Z]+)\$?(\d+)$", cell.upper())
    if not match:
        raise RuntimeError("'%s' is not a valid excel cell address" % cell)
    col, row = match.groups()

    # A = 1
    col_digits = map(lambda c: ord(c) - ord("A") + 1, col)
    col = 0
    for digit in col_digits:
        col = (col * 26) + digit

    row = int(row) - 1
    col = col - 1

    return col, row