本文整理汇总了C#中SS.Spreadsheet.SetContentsOfCell方法的典型用法代码示例。如果您正苦于以下问题:C# Spreadsheet.SetContentsOfCell方法的具体用法?C# Spreadsheet.SetContentsOfCell怎么用?C# Spreadsheet.SetContentsOfCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS.Spreadsheet
的用法示例。
在下文中一共展示了Spreadsheet.SetContentsOfCell方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RunRandomizedTest
public void RunRandomizedTest(int seed, int size)
{
Spreadsheet s = new Spreadsheet();
Random rand = new Random(seed);
for (int i = 0; i < 10000; i++)
{
try
{
switch (rand.Next(3))
{
case 0:
s.SetContentsOfCell(randomName(rand), "3.14");
break;
case 1:
s.SetContentsOfCell(randomName(rand), "hello");
break;
case 2:
s.SetContentsOfCell(randomName(rand), randomFormula(rand));
break;
}
}
catch (CircularException)
{
}
}
ISet<string> set = new HashSet<string>(s.GetNamesOfAllNonemptyCells());
Assert.AreEqual(size, set.Count);
}
示例2: GetCellContentsStringCellExistsTest
public void GetCellContentsStringCellExistsTest()
{
Spreadsheet s = new Spreadsheet();
Assert.AreEqual(true, s.SetContentsOfCell("a1", "Hey there").Contains("a1"));
Assert.AreEqual(true, s.SetContentsOfCell("a1", "What's up?").Contains("a1"));
Assert.AreEqual("What's up?", s.GetCellContents("a1"));
}
示例3: GetCellContentsDoubleCellExistsTest
public void GetCellContentsDoubleCellExistsTest()
{
Spreadsheet s = new Spreadsheet();
Assert.AreEqual(true, s.SetContentsOfCell("a1", "2.0").Contains("a1"));
Assert.AreEqual(true, s.SetContentsOfCell("a1", "5.3").Contains("a1"));
Assert.AreEqual(5.3, s.GetCellContents("a1"));
}
示例4: SetStringContentTwice
public void SetStringContentTwice()
{
Spreadsheet sheet = new Spreadsheet();
sheet.SetContentsOfCell("A1", "blue");
sheet.SetContentsOfCell("A1", "green");
Assert.AreEqual(sheet.GetCellContents("A1"), "green");
Assert.AreNotEqual(sheet.GetCellContents("A1"), "blue");
}
示例5: GetNamesOfAllNonemptyCellsTest
public void GetNamesOfAllNonemptyCellsTest()
{
Spreadsheet s = new Spreadsheet();
s.SetContentsOfCell("a1", "20.0");
s.SetContentsOfCell("a2", "Hey there");
IEnumerable<string> names = s.GetNamesOfAllNonemptyCells();
Assert.AreEqual(true, names.Contains("a1"));
Assert.AreEqual(true, names.Contains("a2"));
}
示例6: 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);
}
示例7: GetCellContentsFormula
public void GetCellContentsFormula()
{
Spreadsheet sheet = new Spreadsheet();
sheet.SetContentsOfCell("A1", "blue");
sheet.SetContentsOfCell("A1", "green");
sheet.SetContentsOfCell("B1", "purple");
sheet.SetContentsOfCell("C1", "red");
sheet.SetContentsOfCell("D1", "=C1 + 2 + X1");
Assert.AreEqual(sheet.GetCellContents("D1"), new Formula("C1+ 2+ X1"));
}
示例8: 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));
}
示例9: GetValueFormula01
public void GetValueFormula01()
{
Spreadsheet sheet = new Spreadsheet(s => true, s => s, "default");
sheet.SetContentsOfCell("D1", "=5");
Assert.AreEqual(sheet.GetCellContents("D1"), new Formula("5"));
Assert.AreEqual(sheet.GetCellValue("D1"), (double)5);
}
示例10: GetCellContentsStringTest
public void GetCellContentsStringTest()
{
//Gets the contents of a string-type cell
Spreadsheet s = new Spreadsheet();
s.SetContentsOfCell("a1", "Hey there");
Assert.AreEqual("Hey there", s.GetCellContents("a1"));
}
示例11: 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"));
}
示例12: 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);
}
示例13: 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);
}
示例14: ChangedTest
public void ChangedTest()
{
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(false, target.Changed);
target.SetContentsOfCell("A1", "33");
Assert.AreEqual(true, target.Changed);
}
示例15: 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);
}