当前位置: 首页>>代码示例>>C#>>正文


C# XLWorkbook.Cell方法代码示例

本文整理汇总了C#中ClosedXML.Excel.XLWorkbook.Cell方法的典型用法代码示例。如果您正苦于以下问题:C# XLWorkbook.Cell方法的具体用法?C# XLWorkbook.Cell怎么用?C# XLWorkbook.Cell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ClosedXML.Excel.XLWorkbook的用法示例。


在下文中一共展示了XLWorkbook.Cell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Cell3

 public void Cell3()
 {
     var wb = new XLWorkbook();
     IXLWorksheet ws = wb.AddWorksheet("Sheet1");
     ws.FirstCell().SetValue(1).AddToNamed("Result");
     IXLCell cell = wb.Cell("Sheet1!Result");
     Assert.IsNotNull(cell);
     Assert.AreEqual(1, cell.GetValue<Int32>());
 }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:9,代码来源:XLWorkbookTests.cs

示例2: CellsUsed

 public void CellsUsed()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     ws.Cell(1, 1);
     ws.Cell(2, 2);
     int count = ws.Range("A1:B2").CellsUsed().Count();
     Assert.AreEqual(0, count);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:8,代码来源:XLCellTests.cs

示例3: IsBlank_false

 public void IsBlank_false()
 {
     var ws = new XLWorkbook().AddWorksheet("Sheet");
     ws.Cell("A1").Value = " ";
     var actual = ws.Evaluate("=IsBlank(A1)");
     Assert.AreEqual(false, actual);
 }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:7,代码来源:IsTests.cs

示例4: IsEmpty2

 public void IsEmpty2()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     IXLCell cell = ws.Cell(1, 1);
     IXLRange range = ws.Range("A1:B2");
     bool actual = range.IsEmpty(true);
     bool expected = true;
     Assert.AreEqual(expected, actual);
 }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:9,代码来源:XLRangeBaseTests.cs

示例5: Double_NaN_is_a_string

        public void Double_NaN_is_a_string()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLCell cell = ws.Cell("A1");
            var doubleList = new List<Double> {0.0/0.0};

            cell.Value = doubleList.AsEnumerable();
            Assert.AreNotEqual(XLCellValues.Number, cell.DataType);
        }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:9,代码来源:XLCellTests.cs

示例6: CellsUsedIncludeStyles2

 public void CellsUsedIncludeStyles2()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     ws.Row(2).Style.Fill.BackgroundColor = XLColor.Red;
     ws.Column(2).Style.Fill.BackgroundColor = XLColor.Red;
     ws.Cell(3, 3).Value = "ASDF";
     var range = ws.RangeUsed(true).RangeAddress.ToString();
     Assert.AreEqual("B2:C3", range);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:9,代码来源:XLCellTests.cs

示例7: IsEmpty5

 public void IsEmpty5()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     IXLCell cell = ws.Cell(1, 1);
     cell.Style.Fill.BackgroundColor = XLColor.Red;
     IXLRange range = ws.Range("A1:B2");
     bool actual = range.IsEmpty(true);
     bool expected = false;
     Assert.AreEqual(expected, actual);
 }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:10,代码来源:XLRangeBaseTests.cs

示例8: ToStringTest

        public void ToStringTest()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLRangeAddress address = ws.Cell(1, 1).AsRange().RangeAddress;

            Assert.AreEqual("A1:A1", address.ToString());

            Assert.AreEqual("A1:A1", address.ToStringRelative());
            Assert.AreEqual("'Sheet1'!A1:A1", address.ToStringRelative(true));

            Assert.AreEqual("$A$1:$A$1", address.ToStringFixed());
            Assert.AreEqual("$A$1:$A$1", address.ToStringFixed(XLReferenceStyle.A1));
            Assert.AreEqual("R1C1:R1C1", address.ToStringFixed(XLReferenceStyle.R1C1));
            Assert.AreEqual("$A$1:$A$1", address.ToStringFixed(XLReferenceStyle.Default));
            Assert.AreEqual("'Sheet1'!$A$1:$A$1", address.ToStringFixed(XLReferenceStyle.A1, true));
            Assert.AreEqual("'Sheet1'!R1C1:R1C1", address.ToStringFixed(XLReferenceStyle.R1C1, true));
            Assert.AreEqual("'Sheet1'!$A$1:$A$1", address.ToStringFixed(XLReferenceStyle.Default, true));
        }
开发者ID:hal1932,项目名称:ClosedXML,代码行数:18,代码来源:XLRangeAddressTests.cs

示例9: AddTextTest1

        public void AddTextTest1()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLCell cell = ws.Cell(1, 1);
            IXLRichText richString = cell.RichText;

            string text = "Hello";
            richString.AddText(text).SetBold().SetFontColor(XLColor.Red);

            Assert.AreEqual(cell.GetString(), text);
            Assert.AreEqual(cell.RichText.First().Bold, true);
            Assert.AreEqual(cell.RichText.First().FontColor, XLColor.Red);

            Assert.AreEqual(1, richString.Count);

            richString.AddText("World");
            Assert.AreEqual(richString.First().Text, text, "Item in collection is not the same as the one returned");
        }
开发者ID:igitur,项目名称:ClosedXML,代码行数:18,代码来源:XLRichStringTests.cs

示例10: AddTextTest2

        public void AddTextTest2()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLCell cell = ws.Cell(1, 1);
            Int32 number = 123;

            cell.SetValue(number).Style
                .Font.SetBold()
                .Font.SetFontColor(XLColor.Red);

            string text = number.ToString();

            Assert.AreEqual(cell.RichText.ToString(), text);
            Assert.AreEqual(cell.RichText.First().Bold, true);
            Assert.AreEqual(cell.RichText.First().FontColor, XLColor.Red);

            Assert.AreEqual(1, cell.RichText.Count);

            cell.RichText.AddText("World");
            Assert.AreEqual(cell.RichText.First().Text, text, "Item in collection is not the same as the one returned");
        }
开发者ID:igitur,项目名称:ClosedXML,代码行数:21,代码来源:XLRichStringTests.cs

示例11: AccessRichTextTest1

        public void AccessRichTextTest1()
        {
            IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
            IXLCell cell = ws.Cell(1, 1);
            cell.RichText.AddText("12");
            cell.DataType = XLCellValues.Number;

            Assert.AreEqual(12.0, cell.GetDouble());

            IXLRichText richText = cell.RichText;

            Assert.AreEqual("12", richText.ToString());

            richText.AddText("34");

            Assert.AreEqual("1234", cell.GetString());

            Assert.AreEqual(XLCellValues.Number, cell.DataType);

            Assert.AreEqual(1234.0, cell.GetDouble());
        }
开发者ID:igitur,项目名称:ClosedXML,代码行数:21,代码来源:XLRichStringTests.cs

示例12: IsEmpty1

 public void IsEmpty1()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     IXLCell cell = ws.Cell(1, 1);
     bool actual = cell.IsEmpty();
     bool expected = true;
     Assert.AreEqual(expected, actual);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:8,代码来源:XLCellTests.cs

示例13: ValueSetToNull

 public void ValueSetToNull()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     IXLCell cell = ws.Cell(1, 1);
     cell.Value = new DateTime(2000, 1, 2);
     cell.Value = null;
     string actual = cell.GetString();
     string expected = String.Empty;
     Assert.AreEqual(expected, actual);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:10,代码来源:XLCellTests.cs

示例14: ValueSetDateWithShortUserDateFormat

 public void ValueSetDateWithShortUserDateFormat()
 {
     // For this test to make sense, user's local date format should be dd/MM/yy (note without the 2 century digits)
     // What happened previously was that the century digits got lost in .ToString() conversion and wrong century was sometimes returned.
     var ci = new CultureInfo(CultureInfo.InvariantCulture.LCID);
     ci.DateTimeFormat.ShortDatePattern = "dd/MM/yy";
     Thread.CurrentThread.CurrentCulture = ci;
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     IXLCell cell = ws.Cell(1, 1);
     var expected = DateTime.Today.AddYears(20);
     cell.Value = expected;
     var actual = (DateTime)cell.Value;
     Assert.AreEqual(expected, actual);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:14,代码来源:XLCellTests.cs

示例15: TryGetValue_TimeSpan_GoodString

 public void TryGetValue_TimeSpan_GoodString()
 {
     IXLWorksheet ws = new XLWorkbook().Worksheets.Add("Sheet1");
     TimeSpan outValue;
     var timeSpan = new TimeSpan(1, 1, 1);
     bool success = ws.Cell("A1").SetValue(timeSpan.ToString()).TryGetValue(out outValue);
     Assert.IsTrue(success);
     Assert.AreEqual(timeSpan, outValue);
 }
开发者ID:jafin,项目名称:ClosedXML-1,代码行数:9,代码来源:XLCellTests.cs


注:本文中的ClosedXML.Excel.XLWorkbook.Cell方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。