本文整理汇总了C#中ClosedXML.Excel.XLWorkbook.NamedRange方法的典型用法代码示例。如果您正苦于以下问题:C# XLWorkbook.NamedRange方法的具体用法?C# XLWorkbook.NamedRange怎么用?C# XLWorkbook.NamedRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClosedXML.Excel.XLWorkbook
的用法示例。
在下文中一共展示了XLWorkbook.NamedRange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WorkbookContainsNamedRange
public void WorkbookContainsNamedRange()
{
var wb = new XLWorkbook();
IXLWorksheet ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().AddToNamed("Name");
Assert.IsTrue(wb.NamedRanges.Contains("Name"));
Assert.IsFalse(wb.NamedRanges.Contains("NameX"));
Assert.IsNotNull(wb.NamedRange("Name"));
Assert.IsNull(wb.NamedRange("NameX"));
IXLNamedRange range1;
Boolean result1 = wb.NamedRanges.TryGetValue("Name", out range1);
Assert.IsTrue(result1);
Assert.IsNotNull(range1);
IXLNamedRange range2;
Boolean result2 = wb.NamedRanges.TryGetValue("NameX", out range2);
Assert.IsFalse(result2);
Assert.IsNull(range2);
}
示例2: NamedRange1
public void NamedRange1()
{
var wb = new XLWorkbook();
IXLNamedRange range = wb.NamedRange("ABC");
Assert.IsNull(range);
}
示例3: NamedRange2
public void NamedRange2()
{
var wb = new XLWorkbook();
IXLWorksheet ws = wb.AddWorksheet("Sheet1");
ws.FirstCell().SetValue(1).AddToNamed("Result", XLScope.Worksheet);
IXLNamedRange range = wb.NamedRange("Sheet1!Result");
Assert.IsNotNull(range);
Assert.AreEqual(1, range.Ranges.Count);
Assert.AreEqual(1, range.Ranges.Cells().Count());
Assert.AreEqual(1, range.Ranges.First().FirstCell().GetValue<Int32>());
}
示例4: NamedRange3
public void NamedRange3()
{
var wb = new XLWorkbook();
IXLWorksheet ws = wb.AddWorksheet("Sheet1");
IXLNamedRange range = wb.NamedRange("Sheet1!Result");
Assert.IsNull(range);
}