本文整理汇总了C#中SS.Spreadsheet.GetNamesOfAllNonemptyCells方法的典型用法代码示例。如果您正苦于以下问题:C# Spreadsheet.GetNamesOfAllNonemptyCells方法的具体用法?C# Spreadsheet.GetNamesOfAllNonemptyCells怎么用?C# Spreadsheet.GetNamesOfAllNonemptyCells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS.Spreadsheet
的用法示例。
在下文中一共展示了Spreadsheet.GetNamesOfAllNonemptyCells方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNamesOfAllNonemptyCellsTest3
public void GetNamesOfAllNonemptyCellsTest3()
{
Spreadsheet test_spreadsheet = new Spreadsheet();
test_spreadsheet.SetCellContents("A1", "x+1");
Assert.AreEqual("A1", new List<string>(test_spreadsheet.GetNamesOfAllNonemptyCells())[0]);
Assert.AreEqual(1, new List<string>(test_spreadsheet.GetNamesOfAllNonemptyCells()).Count);
}
示例2: TestEmptyGetNamesOfCells
public void TestEmptyGetNamesOfCells()
{
Spreadsheet sheet = new Spreadsheet();
var nameEnum = sheet.GetNamesOfAllNonemptyCells().GetEnumerator();
nameEnum.MoveNext();
Assert.IsTrue(nameEnum.Current == null);
}
示例3: 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);
}
示例4: Form1
/// <summary>
/// Constructor for a Spreadsheet Form created from a file
/// </summary>
/// <param name="filename">The name of the file given</param>
public Form1(string filename)
{
InitializeComponent();
ss = new Spreadsheet(filename, Validator, UppercaseString, version);
updateTextBox(spreadsheetPanel1);
//Make sure all the existing cells show up
foreach (string name in ss.GetNamesOfAllNonemptyCells())
{
updateCellValue(name);
}
}
示例5: openToolStripMenuItem_Click
/// <summary>
/// Handle 'Open' from File Menu
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "sprd files (*.sprd)|*.sprd|All files (*.*)|*.*";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
// get hashset of old spreadsheet so that we can add to it and erase old and set new cells
HashSet<string> oldSpread = new HashSet<string> (model.GetNamesOfAllNonemptyCells());
model = new Spreadsheet(openFileDialog1.FileName, s => Regex.IsMatch(s, @"[A-Z][1-9][0-9]?"), s => s.ToUpper(), "PS6");
foreach (string cell in model.GetNamesOfAllNonemptyCells())
{
oldSpread.Add(cell);
}
refresh(oldSpread);
}
}
示例6: SSGUI
//A constructor that takes a file path and attempts to construct a spreadsheet from it. Things may still go wrong.
public SSGUI(string file)
{
InitializeComponent();
//The validity and normalization functions
Func<string, bool> isValid = delegate(string s)
{ return Regex.IsMatch(s, @"[a-zA-Z][1-9][0-9]?"); };
Func<string, string> normalize = delegate(string s)
{ return s.ToUpper(); };
//Link with actual spread sheet
_sheet = new Spreadsheet(file, isValid, normalize, "ps6");
//Set the filepath to the file the spreadsheet opened
filepath = file;
//Loads the values into panel
LoadPanelValues(new HashSet<string>(_sheet.GetNamesOfAllNonemptyCells()));
//Display the first selection correctly.
DisplaySelection(SSPanel);
}
示例7: TestGetNamesOfNonEmptyCells
public void TestGetNamesOfNonEmptyCells()
{
Spreadsheet sheet = new Spreadsheet();
sheet.SetCellContents("A1", 10.5);
sheet.SetCellContents("B1", "horse");
sheet.SetCellContents("E1", 1.5);
sheet.SetCellContents("A", "dad");
var nameEnum = sheet.GetNamesOfAllNonemptyCells().GetEnumerator();
List<object> names = new List<object>();
for (int i = 0; i < 4; i++)
{
nameEnum.MoveNext();
names.Add(nameEnum.Current);
}
Assert.IsTrue(names.Count == 4);
Assert.IsTrue(names.Contains("A1"));
Assert.IsTrue(names.Contains("B1"));
Assert.IsTrue(names.Contains("E1"));
Assert.IsTrue(names.Contains("A"));
}
示例8: TestGetNamesOfAllNonemptyCells1
public void TestGetNamesOfAllNonemptyCells1()
{
Spreadsheet sheet = new Spreadsheet();
sheet.SetContentsOfCell("a1", "0.0");
HashSet<string> correct = new HashSet<string> { "a1" };
HashSet<string> output = (HashSet<string>)sheet.GetNamesOfAllNonemptyCells();
Assert.IsTrue(correct.SetEquals(output));
}
示例9: Test23
public void Test23()
{
Spreadsheet s = new Spreadsheet();
s.SetCellContents("A1", 17.2);
s.SetCellContents("C1", "hello");
s.SetCellContents("B1", new Formula("3.5"));
Assert.IsTrue(new HashSet<string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet<string>() { "A1", "B1", "C1" }));
}
示例10: GetNamesOfAllNonemptyCellsTest5
public void GetNamesOfAllNonemptyCellsTest5()
{
Spreadsheet test_spreadsheet = new Spreadsheet();
HashSet<String> set = new HashSet<string>();
set.Add("A1");
set.Add("B2");
set.Add("C3");
test_spreadsheet.SetCellContents("A1", new Formula("1+a1"));
test_spreadsheet.SetCellContents("B2", new Formula("a1*a1"));
test_spreadsheet.SetCellContents("C3", 5);
IEnumerable<string> real_set;
real_set = test_spreadsheet.GetNamesOfAllNonemptyCells();
foreach (String s in real_set)
Assert.IsTrue(set.Contains(s));
}
示例11: TestAddingEmptyCell
public void TestAddingEmptyCell()
{
Spreadsheet sheet = new Spreadsheet();
sheet.SetCellContents("A1", new Formula("D1"));
sheet.SetCellContents("B1", "purple");
sheet.SetCellContents("C1", 4);
sheet.SetCellContents("A1", "");
sheet.SetCellContents("B1", "");
sheet.SetCellContents("C1", "");
Assert.IsFalse(sheet.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
}
示例12: TestRead3
public void TestRead3()
{
string path = "read3.xml";
Spreadsheet sheet = new Spreadsheet();
sheet.SetContentsOfCell("a1", "=1.5+4");
sheet.SetContentsOfCell("b2", "=a2-2.6");
sheet.SetContentsOfCell("c3", "=3.7*e5");
sheet.SetContentsOfCell("d4", "hil");
sheet.SetContentsOfCell("e5", "5.9");
sheet.Save(path);
HashSet<string> original = (HashSet<string>)sheet.GetNamesOfAllNonemptyCells();
Spreadsheet sheet2 = new Spreadsheet(path, x => true, s => s, "default");
foreach (string s in original) {
Assert.IsTrue(sheet.GetCellContents(s).Equals(sheet2.GetCellContents(s)));
Assert.IsTrue(sheet.GetCellValue(s).Equals(sheet2.GetCellValue(s)));
}
}
示例13: Test1900
public void Test1900()
{
Spreadsheet s = new Spreadsheet();
s.SetContentsOfCell("B1", "");
Assert.IsFalse(s.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
}
示例14: Stress5
public void Stress5()
{
int seed = 47;
int size = 831;
AbstractSpreadsheet s = new Spreadsheet();
Random rand = new Random(seed);
for (int i = 0; i < 1000; 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());
//return size == set.Count;
Assert.AreEqual(size, set.Count);
}
示例15: Test2300
public void Test2300()
{
Spreadsheet s = new Spreadsheet();
s.SetContentsOfCell("A1", "17.2");
s.SetContentsOfCell("C1", "hello");
s.SetContentsOfCell("B1", "=3.5");
Assert.IsTrue(new HashSet<string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet<string>() { "A1", "B1", "C1" }));
}