Spreadsheet Editor is a program heavily inspired by apps such as Excel and Google Sheets. The purpose of this app was to design something similar to it while understanding the logic that goes through calculating arithmetic formulas and mapping them correctly using dependency This application was create in C#.
1️⃣ This area allows you to type any string or initiate a formula with ‘=’ cell dependency
Formulas are calculated using PEMDAS rules with these mathematical symbols:
$$ +, -, /, *, (, ) $$
Example: A1 = [ 3 ] & B1 = [ -3 ] → ‘Cell Contents’ = [ =A1+B1 ] = 0
, But these arithmetic formulas can get more complicated
2️⃣ File menu gives extra features to import and export your work.
Your work is saved in an xml format which includes cells modified by you. Quick example:
<?xml version="1.0" encoding="utf-8"?>
<spreadsheet version="ps6">
<cell>
<name>A1</name>
<contents>SID</contents>
</cell>
<cell>
<name>A2</name>
<contents>STUDENT1</contents>
</cell>
classDiagram
class Formula{
-tokens:List<string>
-variables:HashSet<string>
-formulaString:string
+Formula(formula:string)
+Formula(formula:String, normalize: Func<string, string>, isValid:Func<string, bool>)
+Evaluate(lookup:Func<string, double>) object
+GetVariables() IEnumerable<String>
+Equals(object obj) bool overrides
+==(Formula f1, Formula f2) bool operator
+GetHashCode() override int
-GetTokens(formula String) IEnumerable<string>
-TryGetNumOrVar(token:string , normalize:Func<string, string> , isValid:Func<string, bool> , variables:HashSet<string> , varOrNum:out string ) bool
-IsOperator(token:string ) bool
-CheckFollowingRules(previousToken:string , currentToken:string , prevIsNumOrVar:bool , currIsNumOrVar:bool ) void
+CheckForDivisionOrMultiplication(operators:Stack<string> , values:Stack<double> ) bool
+CheckForAdditionOrSubtraction(operators:Stack<string> , values:Stack<double> ) void
}
class Evaluator{
+Lookup(String v): delegate int
+Evaluate(exp:String , variableEvaluator:Lookup ) int
-ParseIntegerOrVariable(token:string , variableEvaluator:Lookup ) int
}
class stackExtensions{
+OnTop(operators:Stack<string> , operation:string ) bool
+CheckForDivisionOrMultiplication(operators:Stack<string> , values:Stack<int> ) void
+CheckForAdditionOrSubtraction(operators:Stack<string> , values:Stack<int> ) void
}
Evaluator --> stackExtensions
class AbstractSpreadsheet{
+Changed() abstract bool
+IsValid() Func<string, bool>
+Normalize() Func<string, string>
+Version() string
+AbstractSpreadsheet(Func<string, bool> isValid, Func<string, string> normalize, string version)
+GetSavedVersion(String filename) abstract string
+Save(String filename) abstract void
+GetCellValue(String name) object
+GetNamesOfAllNonemptyCells() abstract IEnumerable<String>
+GetCellContents(String name) abstract object
+SetContentsOfCell(String name, String content) abstract IList<String>
#SetCellContents(String name, double number) abstract IList<String>
#SetCellContents(String name, String text) abstract IList<String>
#SetCellContents(String name, Formula formula) abstract IList<String>
#GetDirectDependents(String name) abstract IEnumerable<String>
#GetCellsToRecalculate(string name) IEnumerable<string>
-Visit(string start, string name, ISet<string> visited, LinkedList<string> changed) void
}
class SpreadSheet{
}
class DictionaryExtensions{
public static bool AddSuccessful(this Dictionary<string,HashSet<string>> d, string key, string value)
public static bool RemoveSuccessful(this Dictionary<string, HashSet<string>> d, string key, string value)
public static IEnumerable<string> RetrieveValue(this Dictionary<string, HashSet<string>> d, string key)
}
class DependencyGraph{
private Dictionary<string, HashSet<string>> dependents;
private Dictionary<string, HashSet<string>> dependees;
private int size;
public DependencyGraph()
public int Size
public int this[string s]
public bool HasDependents(string s)
public bool HasDependees(string s)
public IEnumerable<string> GetDependents(string s)
public IEnumerable<string> GetDependees(string s)
public void AddDependency(string s, string t)
public void RemoveDependency(string s, string t)
public void ReplaceDependents(string s, IEnumerable<string> newDependents)
public void ReplaceDependees(string s, IEnumerable<string> newDependees)
}
Formula --> SpreadSheet
Formula --> DependencyGraph
SpreadSheet --* AbstractSpreadsheet
SpreadSheet --> DependencyGraph
DictionaryExtensions --> DependencyGraph
Evaluator --> Formula
class SpreadsheetApplicationContext{
-formCount: int
+getAppContext() SpreadsheetApplicationContext
+RunForm(Form form) void
}