+ @"|(?<=\W)(?<three>\$?[a-zA-Z]{1,3}:\$?[a-zA-Z]{1,3})(?=\W)", RegexOptions.Compiled); // A:A private static string Evaluator(Match match, Int32 row, String column) { if (match.Groups["one"].Success) { var split = match.Groups["one"].Value.Split('$'); if (split.Length == 1) { return(column + row); // A1 } if (split.Length == 3) { return(match.Groups["one"].Value); // $A$1 } var a = XLAddress.Create(match.Groups["one"].Value); if (split[0] == String.Empty) { return("$" + a.ColumnLetter + row); // $A1 } return(column + "$" + a.RowNumber); } if (match.Groups["two"].Success) { return(ReplaceGroup(match.Groups["two"].Value, row.ToString())); } return(ReplaceGroup(match.Groups["three"].Value, column)); }
public XLRangeAddress(XLWorksheet worksheet, String rangeAddress) { string addressToUse = rangeAddress.Contains("!") ? rangeAddress.Substring(rangeAddress.IndexOf("!") + 1) : rangeAddress; string firstPart; string secondPart; if (addressToUse.Contains(':')) { var arrRange = addressToUse.Split(':'); firstPart = arrRange[0]; secondPart = arrRange[1]; } else { firstPart = addressToUse; secondPart = addressToUse; } if (XLHelper.IsValidA1Address(firstPart)) { FirstAddress = XLAddress.Create(worksheet, firstPart); LastAddress = XLAddress.Create(worksheet, secondPart); } else { firstPart = firstPart.Replace("$", String.Empty); secondPart = secondPart.Replace("$", String.Empty); if (char.IsDigit(firstPart[0])) { FirstAddress = XLAddress.Create(worksheet, "A" + firstPart); LastAddress = XLAddress.Create(worksheet, XLHelper.MaxColumnLetter + secondPart); } else { FirstAddress = XLAddress.Create(worksheet, firstPart + "1"); LastAddress = XLAddress.Create(worksheet, secondPart + XLHelper.MaxRowNumber.ToInvariantString()); } } Worksheet = worksheet; }
public XLRangeAddress(XLAddress firstAddress, XLAddress lastAddress) { Worksheet = firstAddress.Worksheet; FirstAddress = XLAddress.Create(firstAddress); LastAddress = XLAddress.Create(lastAddress); }