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


C# Spreadsheet.Save方法代码示例

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


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

示例1: TestConstructor

        public void TestConstructor()
        {
            //just some stuff with filewriting
            Assert.IsTrue(sheet1.IsValid("any old string"));
            Assert.IsTrue(sheet1.Normalize("dead") == "dead");
            Assert.IsTrue(sheet1.Version == "default");

            //test 3 arg constructor
            sheet1 = new Spreadsheet(s => (s.Length >= 2) ? true : false,
                s => s.Replace(" ", ""),
                "version1");
            Assert.IsTrue(sheet1.IsValid("A1"));
            Assert.IsFalse(sheet1.IsValid("A"));
            Assert.IsTrue(sheet1.Normalize("d e a d") == "dead");
            Assert.IsTrue(sheet1.Version == "version1");
            sheet1.SetContentsOfCell("A     1","loaded!");

            string savePath = "save 1.xml";
            sheet1.Save(savePath);
            sheet1 = new Spreadsheet(
                savePath,
                s => (s.Length >= 2) ? true : false,
                s => s.Replace(" ", ""),
                "version1");
            Assert.AreEqual("loaded!",(string)sheet1.GetCellContents("A1"));
        }
开发者ID:jiiehe,项目名称:cs3500,代码行数:26,代码来源:SpreadsheetTests.cs

示例2: NewTest11

 public void NewTest11()
 {
     Spreadsheet s = new Spreadsheet(x => true, x => x, "\"default\"");
     s.SetContentsOfCell("a1", "Text");
     s.Save("..\\..\\..\\Test.xml");
     string sversion = s.GetSavedVersion("..\\..\\..\\Test.xml");
     Assert.AreEqual("\"default\"", sversion);
 }
开发者ID:hodgeskyjon,项目名称:3505_Spring_Project,代码行数:8,代码来源:UnitTest1.cs

示例3: Changed

        public void Changed()
        {
            // Make sure it starts false
            AbstractSpreadsheet s = new Spreadsheet();
            Assert.IsFalse(s.Changed);

            // Modify a file, see if changed is true; Use SetContentsOfCell
            s.SetContentsOfCell("Z7", "1.5");
            Assert.IsTrue(s.Changed);

            // Save a file after modifying, see if it switches back to false
            s.Save("changed_test.xml");
            Assert.IsFalse(s.Changed);
        }
开发者ID:jam98,项目名称:Spreadsheet,代码行数:14,代码来源:SpreadsheetTest.cs

示例4: 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

示例5: TestRead1

 public void TestRead1()
 {
     string path = "read1.xml";
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("a1", "1.5");
     sheet.SetContentsOfCell("b2", "2.6");
     sheet.SetContentsOfCell("c3", "3.7");
     sheet.SetContentsOfCell("d4", "4.8");
     sheet.SetContentsOfCell("e5", "5.9");
     sheet.Save(path);
     sheet = new Spreadsheet(path, x => true, s => s, "default");
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:12,代码来源:MyUnitTests.cs

示例6: TestGetChanged1

 public void TestGetChanged1()
 {
     string path = "GetChanged1.xml";
     Spreadsheet sheet = new Spreadsheet();
     Assert.IsTrue(!sheet.Changed);
     sheet.SetContentsOfCell("a1", "hello");
     Assert.IsTrue(sheet.Changed);
     sheet.Save(path);
     Assert.IsTrue(!sheet.Changed);
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:10,代码来源:MyUnitTests.cs

示例7: 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

示例8: SaveTest3

 public void SaveTest3()
 {
     AbstractSpreadsheet s1 = new Spreadsheet();
     Set(s1, "A1", "hello");
     s1.Save("save1.txt");
     s1 = new Spreadsheet("save1.txt", s => true, s => s, "default");
     Assert.AreEqual("hello", s1.GetCellContents("A1"));
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:8,代码来源:MyUnitTests.cs

示例9: MediumSave

 public void MediumSave()
 {
     AbstractSpreadsheet ss = new Spreadsheet();
     MediumSheet(ss);
     ss.Save("save7.txt");
     ss = new Spreadsheet("save7.txt", s => true, s => s, "default");
     VV(ss, "A1", 2.0, "A2", 2.0, "A3", 3.0, "A4", 4.0, "B1", 1.0, "B2", 12.0, "C1", 13.0);
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:8,代码来源:MyUnitTests.cs

示例10: TestSavedVersion1

 public void TestSavedVersion1()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("a1", "hello");
     string path = "savedVersion1.xml";
     sheet.Save(path);
     string version = "default";
     Assert.AreEqual(version, sheet.GetSavedVersion(path));
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:9,代码来源:MyUnitTests.cs

示例11: TestSave1

 public void TestSave1()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetContentsOfCell("a1", "12.03");
     sheet.Save("test1.xml");
 }
开发者ID:unaveed,项目名称:Spreadsheet,代码行数:6,代码来源:MyUnitTests.cs

示例12: SaveTest5

        public void SaveTest5()
        {
            AbstractSpreadsheet ss = new Spreadsheet();
            Set(ss, "A1", "hello");
            Set(ss, "A2", "5.0");
            Set(ss, "A3", "4.0");
            Set(ss, "A4", "= A2 + A3");
            StringWriter sw = new StringWriter();
            ss.Save(sw);

            using (XmlReader reader = XmlReader.Create(new StringReader(sw.ToString())))
            {
                int spreadsheetCount = 0;
                int cellCount = 0;

                while (reader.Read())
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name)
                        {
                            case "spreadsheet":
                                Assert.IsTrue(new Regex(reader["IsValid"]).IsMatch("a4"));
                                spreadsheetCount++;
                                break;

                            case "cell":
                                string name = reader["name"];
                                string contents = reader["contents"];
                                if (name.Equals("A1")) { Assert.AreEqual("hello", contents); }
                                else if (name.Equals("A2")) { Assert.AreEqual(5.0, Double.Parse(contents), 1e-9); }
                                else if (name.Equals("A3")) { Assert.AreEqual(4.0, Double.Parse(contents), 1e-9); }
                                else if (name.Equals("A4")) { contents = contents.Replace(" ", ""); Assert.AreEqual("=A2+A3", contents); }
                                else Assert.Fail();
                                cellCount++;
                                break;
                        }
                    }
                }
                Assert.AreEqual(1, spreadsheetCount);
                Assert.AreEqual(4, cellCount);
            }
        }
开发者ID:UofU-CS3500-S16,项目名称:spreadsheet,代码行数:43,代码来源:GradingTests.cs

示例13: SaveTest3

 public void SaveTest3()
 {
     AbstractSpreadsheet ss = new Spreadsheet(new Regex("^[b-zB-Z]+[0-9]+"));
     ss.SetContentsOfCell("B1", "5");
     StringWriter sw = new StringWriter();
     ss.Save(sw);
     ss = new Spreadsheet(new StringReader(sw.ToString()));
     try
     {
         ss.SetContentsOfCell("A1", "5");
     }
     catch (InvalidNameException)
     {
         return;
     }
     Assert.Fail();
 }
开发者ID:UofU-CS3500-S16,项目名称:spreadsheet,代码行数:17,代码来源:GradingTests.cs

示例14: SaveTest1

 public void SaveTest1()
 {
     AbstractSpreadsheet s1 = new Spreadsheet();
     Set(s1, "A1", "hello");
     StringWriter sw = new StringWriter();
     s1.Save(sw);
     s1 = new Spreadsheet(new StringReader(sw.ToString()));
     Assert.AreEqual("hello", s1.GetCellContents("A1"));
 }
开发者ID:UofU-CS3500-S16,项目名称:spreadsheet,代码行数:9,代码来源:GradingTests.cs

示例15: Changed3

 public void Changed3()
 {
     AbstractSpreadsheet ss = new Spreadsheet();
     Assert.IsFalse(ss.Changed);
     Set(ss, "C1", "17.5");
     Assert.IsTrue(ss.Changed);
     ss.Save(new StringWriter());
     Assert.IsFalse(ss.Changed);
 }
开发者ID:UofU-CS3500-S16,项目名称:spreadsheet,代码行数:9,代码来源:GradingTests.cs


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