I am looking to parse and extract cell references from Excel formulas. Let's say I have the following formula inside cell P5
:
=SUM(P1:P4)+Q3
I am looking for an output of the location of the cells involved for the formula to produce an answer, i.e. P1
, P2
, P3
, P4
, Q3
as output (their location/representation in some other form is acceptable too).
My question is whether there is such kind of parser available to accomplish this and if not, what technique I should adopt. Perhaps the formula I have listed as example is quite simple, I would ideally like to cover all potential formulas, maybe even those that have a reference across other sheets and workbooks. I expected and was really hoping for a VSTO C# based solution but I'm having a really difficult time finding one or even relevant functionality in the VSTO library.