1) Excel Formula classification
A. Numerical value: In extreme cases, the numerical value is also one of the simplest formulas such as a1=1;
B. Simple function: Simple function refers to the function of the parameter can only be numeric, such as formula A3 (Simple function) =sum (A1:A2), a1=1,a2=3;
C. Complex functions: A complex function refers to a function in a parameter, such as A4 (complex function) =avg (A3,A1);
D. Expression: refers to the arithmetic expression, such as a5= (A4+A1)/a3;
Within the scope of my existing knowledge, Excel Formula function is more than four kinds of cases.
2) Excel Formula parsing--recursion
The arithmetic expression in the most complex class D above requires that the value of A5 be required first, and the value of A4 is required, and the value of A3 and A1 must be calculated. This is a layer of recursion. After the A1, A3 and A4 values are finally calculated, the four +-*/operation is required.
Summary: In general, the parse order is numeric--and simple---complex functions--expressions.
As can be seen, in fact, formula parsing is a tree traversal process, where the leaf nodes are values.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java implementation Excel Formula Special topic (i)--excel formula Classification and resolution steps