What is the data structure used by spreadsheets program like ms-excel?
Asked
Active
Viewed 8,129 times
12
-
1Are you interested in the means of storing the contents of the cells, or of storing and keeping track of the many cells, or both? – dmckee --- ex-moderator kitten Feb 08 '09 at 18:31
5 Answers
3
I got this question in an interview today.
The answer they were looking for (because I asked the interviewer at the end) was to implement a class structure that used multiple objects; formulas, references, and numerics.
Not much more detail to offer but suffice it to say that programs like google docs are much more interesting (to code) than they seem.

Wade Williams
- 3,943
- 1
- 26
- 35
3
While it is not exactly Excel, Open Office's Spreadsheet program is open source. It's a fairly large code base but nevertheless giving it a peek might give you a better understanding of how such an application is implemented:

BobbyShaftoe
- 28,337
- 7
- 52
- 74
0
Possibly a multi-dimensional array.

Bravax
- 10,453
- 7
- 40
- 68
-
1That may have been the case for early spreadsheets with naive implementations that limited rows and columns to a quantity that could fit in memory, but it's doubtful any successful implementation would suffer such constraints as a 2D array would impose. The art is to give the feel of a 2D array without actually being a 2D array. – DavidO Aug 02 '15 at 15:36
-
Since someone asked me directly via email what I meant by this comment, a spreadsheet's underlying datastructure is typically a directed acyclic graph, to create a sparse array. What is seen on screen is really just the view of a traversal of the data model in a row/column order, where the row/column information is just contained within each vertex along with the payload. – DavidO Dec 25 '21 at 09:07