Simple Sheet: Spreadsheet Application
C#, .NET MAUI, MVC, JSON
Oct. 6, 2023
CS 3500 - Software Practice I
A lightweight spreadsheet application designed for everyday use. Organize data and make simple calculations without the clutter of advanced tools.
A spreadsheet consists of cells that can have one-way relationships with other cells. This structure is best represented as a Directed Acyclic Graph (DAG). DAGs can have multiple source nodes (nodes without parents) and multiple sink nodes (nodes without children). Modeling a spreadsheet as a DAG allows us to detect and notify the user if they accidentally introduce a cycle. Detecting cycles can be done efficiently using a modified Depth First Search algorithm.
Formula evaluation requires two stacks to process tokens: one for values and one for operations. Numbers and resolved variables are pushed onto the value stack, while operators and parentheses go onto the operation stack. Multiplication and division are applied immediately to respect operator precedence, followed by addition and subtraction in the correct order. When a closing parenthesis is encountered, all operations within that scope are evaluated. This stack-based approach ensures the formula is processed correctly, handling precedence and parentheses while also detecting errors like division by zero.
The MVC pattern fits this spreadsheet project well by enforcing a clear separation of concerns. The Model handles spreadsheet logic—storing cell contents, detecting circular dependencies, and evaluating formulas. The View is “dumb,” focused solely on presenting data and providing a polished UI. The Controller is lightly tied to the Model and primarily interacts with the View through event subscriptions. When the Model changes, the View responds to those events to update the display.
Show me the code...