public void WsNamedRangesOneString() { var wb = new XLWorkbook(); IXLWorksheet ws = wb.Worksheets.Add("Sheet1"); ws.NamedRanges.Add("TestRange", "Sheet1!$A$1,Sheet1!$A$3"); IXLRanges namedRanges = ws.Ranges("TestRange"); Assert.AreEqual("$A$1:$A$1", namedRanges.First().RangeAddress.ToStringFixed()); Assert.AreEqual("$A$3:$A$3", namedRanges.Last().RangeAddress.ToStringFixed()); }
public void Ranges3() { var wb = new XLWorkbook(); IXLWorksheet ws = wb.AddWorksheet("Sheet1"); ws.FirstCell().SetValue(1).AddToNamed("Result"); IXLRanges ranges = wb.Ranges("Sheet1!Result, ABC"); Assert.IsNotNull(ranges); Assert.AreEqual(1, ranges.Cells().Count()); Assert.AreEqual(1, ranges.First().FirstCell().GetValue <Int32>()); }
public void WsNamedRanges() { var wb = new XLWorkbook(); IXLWorksheet ws = wb.Worksheets.Add("Sheet1"); ws.Cell(1, 1).SetValue("A"); ws.Cell(2, 1).SetValue("B"); ws.Cell(3, 1).SetValue("C"); IXLRange original = ws.Range("A1:A2"); original.AddToNamed("TestRange", XLScope.Worksheet); IXLRanges namedRanges = ws.Ranges("TestRange, A3"); Assert.AreEqual(original.RangeAddress.ToStringFixed(), namedRanges.First().RangeAddress.ToString()); Assert.AreEqual("$A$3:$A$3", namedRanges.Last().RangeAddress.ToStringFixed()); }