Hi Ralston! I'm building a spreadsheet program myself at the moment (demo and product link at
https://6gu.nz).
There are two major parts to a spreadsheet app, in my view:
1. A UI to change sheet layout and formulas, and to view computed values.
2. A "programming language"-like engine to derive computed values from the formulas and sheet layout.
In (2) you also have to do a bit of topological sorting to make sure you compute things in the right order, but it's not terribly tricky.
A spreadsheet is kinda like a REPL, where the "R" and "P" are the spreadsheet UI and the "E" is the programming language part.
In Excel and Google Sheets (but not in my program) there are some fun data structures you might use to make formulas like `SUM(A:A)` (i.e., sum the whole column) run in a reasonable amount of time. Essentially, data structures that take advantage of the sparsity of the grid. I don't know off-hand the best way to go about something like that, but if you didn't want to invent anything yourself I guess you could just throw everything into an off-the-shelf spatial acceleration structure (an r-tree or a quadtree or something.)
There's quite a big surface area to the problem, if there's something more specific you want to know, please ask! I can't promise to respond quickly, but I should get back sooner or later.