public static ((int Column, int Row), (int Column, int Row))? TranslateRange(this System.Data.DataTable table, string range) { ArgumentGuards.GuardAgainstNullRange(range); range = TranslateUnknown(table, range); var tuple = CellRange.Translate(range, Offset.ZeroBased); if (!table.Contains(tuple)) { return(null); } return(tuple); }
public static string Shift(this System.Data.DataTable table, string range, string toColumn) { ArgumentGuards.GuardAgainstNullTable(table); ArgumentGuards.GuardAgainstNullRange(range); if (string.IsNullOrEmpty(toColumn)) { throw new ArgumentNullException(nameof(toColumn)); } var tuple = table.TranslateRange(range); if (!tuple.HasValue) { throw new ArgumentOutOfRangeException(nameof(range), $"The data table does not contain the range {range}."); } if (!CellRange.IsSameColumn(tuple.Value)) { throw new ArgumentException("A shift cannot be performed across multiple columns.", nameof(range)); } return($"{toColumn}{tuple.Value.Item1.Row + 1}:{toColumn}{tuple.Value.Item2.Row + 1}"); }