本文整理汇总了C#中ClosedXML.Excel.XLWorkbook.Ranges方法的典型用法代码示例。如果您正苦于以下问题:C# XLWorkbook.Ranges方法的具体用法?C# XLWorkbook.Ranges怎么用?C# XLWorkbook.Ranges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClosedXML.Excel.XLWorkbook
的用法示例。
在下文中一共展示了XLWorkbook.Ranges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Ranges3
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>());
}
示例2: WbNamedRanges
public void WbNamedRanges()
{
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").AddToNamed("Test2");
IXLRange original = ws.Range("A1:A2");
original.AddToNamed("TestRange");
IXLRanges wbRanges = wb.Ranges("TestRange, Test2");
Assert.AreEqual(original.RangeAddress.ToStringFixed(), wbRanges.First().RangeAddress.ToString());
Assert.AreEqual("$A$3:$A$3", wbRanges.Last().RangeAddress.ToStringFixed());
IXLRanges wsRanges = wb.Ranges("TestRange, Test2");
Assert.AreEqual(original.RangeAddress.ToStringFixed(), wsRanges.First().RangeAddress.ToString());
Assert.AreEqual("$A$3:$A$3", wsRanges.Last().RangeAddress.ToStringFixed());
}
示例3: Ranges1
public void Ranges1()
{
var wb = new XLWorkbook();
IXLRanges ranges = wb.Ranges("ABC");
Assert.IsNotNull(ranges);
Assert.AreEqual(0, ranges.Count());
}