public static GridReference valueOf(String s) {
        if (s == null)
            return null;
        s = s.toUpperCase().trim();
        int len = s.length();
        if (len == 0)
            return null;
        while (len > 0 && Character.isDigit(s.charAt(len - 1)))
            len--;
        String column = s.substring(0, len);
        int row = 0;
        try {
            String b = s.substring(len);
            row = Integer.parseInt(b);
        } catch (Exception e) {
            return null;
        }

        if (column.length() == 0)
            return null;

        boolean columnFixed = false;
        boolean rowFixed = false;

        if (column.charAt(0) == '$') {
            columnFixed = true;
            column = column.substring(1);
        }

        if (column.endsWith("$")) {
            rowFixed = true;
            column = column.substring(0, column.length() - 1);
        }

        if (!isValidVariable(column))
            return null;

        GridReference gf = new GridReference(toColumnIndex(column), row);
        gf.setColumnFixed(columnFixed);
        gf.setRowFixed(rowFixed);

        return gf;
    }