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


C# Spreadsheet.GetCellValue方法代码示例

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


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

示例1: NewTest1

 public void NewTest1()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("A1", "3");
     sheet.SetContentsOfCell("B1", "=A1");
     Assert.AreEqual(sheet.GetCellValue("B1"), 3.0);
     sheet.SetContentsOfCell("A1", "");
     Assert.IsTrue(sheet.GetCellValue("B1") is FormulaError);
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:9,代码来源:MyUnitTests.cs

示例2: GetCellValueTest

        public void GetCellValueTest()
        {
            AbstractSpreadsheet s = new Spreadsheet();
            string name;
            string content;
            // Try a value of a string from string
            name = "A1";
            content = "Hello";
            s.SetContentsOfCell(name, content);
            string expected1 = content;
            string actual1 = (string)s.GetCellValue(name);
            Assert.AreEqual(expected1, actual1);

            // Try a value of a double from a double
            name = "B1";
            content = "3";
            s.SetContentsOfCell(name, content);
            double expected2 = 3;
            double actual2 = (double)s.GetCellValue(name);
            Assert.AreEqual(expected2, actual2);

            // Try a value of a double from a Formula
            name = "C1";
            content = "=3+1";
            s.SetContentsOfCell(name, content);
            double expected3 = 4;
            double actual3 = (double)s.GetCellValue(name);
            Assert.AreEqual(expected3, actual3);

            // Try all possible FormulaError
            name = "D1";
            content = "=1/0";
            s.SetContentsOfCell(name, content);
            object actual4 = s.GetCellValue(name);
            Assert.IsInstanceOfType(actual4, typeof(FormulaError));

            // Try chaining several formulas together then changing the value of cell. Test before and after.
            s.SetContentsOfCell("E1", "=F1 + 1");
            s.SetContentsOfCell("F1", "=G1 + 1");
            s.SetContentsOfCell("G1", "1");
            Assert.AreEqual(3, (double)s.GetCellValue("E1"));
            Assert.AreEqual(2, (double)s.GetCellValue("F1"));

            s.SetContentsOfCell("G1", "2");
            Assert.AreEqual(4, (double)s.GetCellValue("E1"));
            Assert.AreEqual(3, (double)s.GetCellValue("F1"));

            // Try switching a cell that has a formula depending on it to string.
            s.SetContentsOfCell("J1", "This is a string");
            s.SetContentsOfCell("K1", "=J1");
            Assert.IsInstanceOfType(s.GetCellValue("K1"), typeof(FormulaError));
        }
开发者ID:jam98,项目名称:Spreadsheet,代码行数:52,代码来源:SpreadsheetTest.cs

示例3: GetValueDouble

 public void GetValueDouble()
 {
     Spreadsheet sheet = new Spreadsheet(s => true, s => s, "default");
     sheet.SetContentsOfCell("D1", "5");
     Assert.AreEqual(sheet.GetCellContents("D1"), (double)5);
     Assert.AreEqual(sheet.GetCellValue("D1"), (double)5);
 }
开发者ID:drewmacmac,项目名称:old_class,代码行数:7,代码来源:PS5Tester.cs

示例4: GetValueDoubleEmptyConstructor

 public void GetValueDoubleEmptyConstructor()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("D1", "5");
     Assert.AreEqual(sheet.GetCellContents("D1"), (double)5);
     Assert.AreEqual(sheet.GetCellValue("D1"), (double)5);
 }
开发者ID:drewmacmac,项目名称:old_class,代码行数:7,代码来源:PS5Tester.cs

示例5: CreateSaveLoadSpreadsheet

 public void CreateSaveLoadSpreadsheet()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("D1", "=5");
     sheet.SetContentsOfCell("C1", "=4.5");
     sheet.SetContentsOfCell("E1", "apples");
     sheet.SetContentsOfCell("G1", "-2");
     sheet.SetContentsOfCell("H1", "-4");
     sheet.SetContentsOfCell("F1", "= G1 + H1");
     sheet.Save(@"MyXml2.xml");
     Spreadsheet sheet2 = new Spreadsheet(@"MyXml2.xml", s => true, s => s, "default");
     Assert.AreEqual(sheet2.GetCellContents("D1"), new Formula("5"));
     Assert.AreEqual(sheet2.GetCellContents("C1"), new Formula("4.5"));
     Assert.AreEqual(sheet2.GetCellContents("E1"), "apples");
     Assert.AreEqual(sheet2.GetCellContents("G1"), (double)-2);
     Assert.AreEqual(sheet2.GetCellContents("H1"), (double)-4);
     Assert.AreEqual(sheet2.GetCellContents("F1"), new Formula("G1 + H1"));
     Assert.AreEqual(sheet2.GetCellValue("F1"), (double)-6);
 }
开发者ID:drewmacmac,项目名称:old_class,代码行数:19,代码来源:PS5Tester.cs

示例6: NewTest16

 public void NewTest16()
 {
     Spreadsheet s = new Spreadsheet(x => true, x => x, "default");
     s.GetCellValue("1a");
 }
开发者ID:hodgeskyjon,项目名称:3505_Spring_Project,代码行数:5,代码来源:UnitTest1.cs

示例7: LongTest

 public void LongTest()
 {
     AbstractSpreadsheet s = new Spreadsheet();
     s.SetContentsOfCell("sum1", "= a1 + a2");
     int i;
     int depth = 100;
     for (i = 1; i <= depth * 2; i += 2)
     {
         s.SetContentsOfCell("a" + i, "= a" + (i + 2) + " + a" + (i + 3));
         s.SetContentsOfCell("a" + (i + 1), "= a" + (i + 2) + "+ a" + (i + 3));
     }
     s.SetContentsOfCell("a" + i, "1");
     s.SetContentsOfCell("a" + (i + 1), "1");
     Assert.AreEqual(Math.Pow(2, depth + 1), (double)s.GetCellValue("sum1"), 1e20);
     s.SetContentsOfCell("a" + i, "0");
     Assert.AreEqual(Math.Pow(2, depth), (double)s.GetCellValue("sum1"), 1e20);
     s.SetContentsOfCell("a" + (i + 1), "0");
     Assert.AreEqual(0.0, (double)s.GetCellValue("sum1"), 0.1);
 }
开发者ID:UofU-CS3500-S16,项目名称:spreadsheet,代码行数:19,代码来源:GradingTests.cs

示例8: SaveTest

        public void SaveTest()
        {
            string existing_path = @"..\..\..\SpreadSheetTests\validspreadsheet.xml"; // the .. means up a directory

            Spreadsheet target = new Spreadsheet(existing_path, s => true, s => s.ToUpper(), "dan1");
            Assert.AreEqual(2.0, (double)target.GetCellValue("a2"));
            target.Save(@"output22.xml");
            var output = File.ReadAllText("output22.xml");
            Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-8\"?><spreadsheet version=\"dan1\"><cell><name>A1</name><contents>2</contents></cell><cell><name>A2</name><contents>=A1</contents></cell></spreadsheet>", output);
        }
开发者ID:amozoss,项目名称:CS3505,代码行数:10,代码来源:SpreadsheetTest.cs

示例9: SpreadsheetFourArgumentConstructorTest

 public void SpreadsheetFourArgumentConstructorTest()
 {
     if (!File.Exists("fourarg.xml"))
     {
         Spreadsheet old = new Spreadsheet(TestValidToTrue, TestNormalizeToUpperCase, "2.2");
         old.SetContentsOfCell("A1", "asdf");
         old.SetContentsOfCell("B2", "23");
         old.Save("fourarg.xml");
     }
     Spreadsheet s = new Spreadsheet("fourarg.xml", TestValidToTrue, TestNormalizeToUpperCase, "2.2");
     Assert.AreEqual(true, s.IsValid("a"));
     Assert.AreEqual("A", s.Normalize("a"));
     Assert.AreEqual("asdf", s.GetCellContents("A1"));
     Assert.AreEqual(23.0, s.GetCellContents("B2"));
     Assert.AreEqual(23.0, s.GetCellValue("B2"));
     Assert.AreEqual("2.2", s.Version);
 }
开发者ID:Buck417,项目名称:Second-Half-CS-3500,代码行数:17,代码来源:SpreadsheetTests.cs

示例10: NormalizeTest4

 public void NormalizeTest4()
 {
     AbstractSpreadsheet ss = new Spreadsheet(s => true, s => s.ToUpper(), "");
     ss.SetContentsOfCell("a1", "5");
     ss.SetContentsOfCell("A1", "6");
     ss.SetContentsOfCell("B1", "= a1");
     Assert.AreEqual(6.0, (double)ss.GetCellValue("B1"), 1e-9);
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:8,代码来源:MyUnitTests.cs

示例11: LongFormulaHelper

 public void LongFormulaHelper(out object result)
 {
     try {
         AbstractSpreadsheet s = new Spreadsheet();
         s.SetContentsOfCell("sum1", "= a1 + a2");
         int i;
         int depth = 100;
         for (i = 1; i <= depth * 2; i += 2) {
             s.SetContentsOfCell("a" + i, "= a" + (i + 2) + " + a" + (i + 3));
             s.SetContentsOfCell("a" + (i + 1), "= a" + (i + 2) + "+ a" + (i + 3));
         }
         s.SetContentsOfCell("a" + i, "1");
         s.SetContentsOfCell("a" + (i + 1), "1");
         Assert.AreEqual(Math.Pow(2, depth + 1), (double)s.GetCellValue("sum1"), 1.0);
         s.SetContentsOfCell("a" + i, "0");
         Assert.AreEqual(Math.Pow(2, depth), (double)s.GetCellValue("sum1"), 1.0);
         s.SetContentsOfCell("a" + (i + 1), "0");
         Assert.AreEqual(0.0, (double)s.GetCellValue("sum1"), 0.1);
         result = "ok";
     }
     catch (Exception e) {
         result = e;
     }
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:24,代码来源:MyUnitTests.cs

示例12: TestGetCellValue2

 public void TestGetCellValue2()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.GetCellValue("84");
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:5,代码来源:MyUnitTests.cs

示例13: NewTest15

 public void NewTest15()
 {
     Spreadsheet s = new Spreadsheet(x => true, x => x.Replace('a', '1'), "default");
     s.SetContentsOfCell("a1", "Text");
     s.GetCellValue("a1");
 }
开发者ID:hodgeskyjon,项目名称:3505_Spring_Project,代码行数:6,代码来源:UnitTest1.cs

示例14: NewTest19

 public void NewTest19()
 {
     Spreadsheet s = new Spreadsheet(x => true, x => x.Replace('a', '1'), "default");
     s.GetCellValue("a1");
 }
开发者ID:hodgeskyjon,项目名称:3505_Spring_Project,代码行数:5,代码来源:UnitTest1.cs

示例15: GetValueFormulaMultipleCellLayers02

        public void GetValueFormulaMultipleCellLayers02()
        {
            Spreadsheet sheet = new Spreadsheet();
            Assert.IsTrue(!sheet.Changed);
            sheet.SetContentsOfCell("D1", "=5");
            Assert.IsTrue(sheet.Changed);
            sheet.SetContentsOfCell("C1", "=4.5");
            sheet.SetContentsOfCell("E1", "0.5");
            sheet.SetContentsOfCell("G1", "-2");
            sheet.SetContentsOfCell("H1", "-4");
            sheet.SetContentsOfCell("F1", "= G1 + H1");
            Assert.AreEqual(sheet.GetCellValue("D1"), (double)5);
            Assert.AreEqual(sheet.GetCellValue("C1"), (double)4.5);
            Assert.AreEqual(sheet.GetCellValue("E1"), (double)0.5);
            Assert.AreEqual(sheet.GetCellValue("F1"), (double)-6);
            Assert.AreEqual(sheet.GetCellValue("G1"), (double)-2);

            sheet.SetContentsOfCell("B1", "=(C1 + D1)/E1 + F1");
            Assert.AreEqual(sheet.GetCellContents("B1"), new Formula("(C1 + D1)/E1 + F1"));
            Assert.AreEqual(sheet.GetCellValue("B1"), (double)13);
        }
开发者ID:drewmacmac,项目名称:old_class,代码行数:21,代码来源:PS5Tester.cs


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