reverse engineering Excel spreadsheet
Bart Willems
b.r.willems at gmail.com
Mon Apr 2 21:16:02 EDT 2007
John Machin wrote:
> I'm a bit puzzled by your notion of creating a dependency graph
> *without* first extracting the "relationships (functions)" [which you
> could do only by parsing the formulas and macros].
Not really. The range object in the Excel object model has a Dependents
attribute, although for creating a graph you might want to rely on
DirectDependents for obvious reasons. There's no reason to parse
You can use that for each cell to get a list of the cells that have
their formulas depending on the cell you are interrogating. There's also
a Precedents and DirectPrecedents property if you want to walk the trees
in the other direction. :-)
More important, get some *serious* books about Excel VBA programming (I
can recommend Walkenbach's Power Programming). Excel has a an extremely
complex object model that can do almost anything for you - writing code
against Excel without knowledge of that data will mean that you'll be
writing 100 lines of Python code (for instance, to parse formulas) to do
something that could have been done in 5 lines of Visual Basic code (or
Python for that matter, but I can make a better point by using VBA :) ).
Best Regards,
Bart
More information about the Python-list
mailing list